Java Easy Solution||  checkArithmeticSubarrays
Intuition\n Describe your first thoughts on how to solve this problem. \nJava Solution||Easy to understand, very simple & clean code\n# Approach\n Describe your
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nJava Solution||Easy to understand, very simple & clean code\n# Approach\n<!-- Describe your approach to solving the problem. -->\nusing for loop\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(MN)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(l)\n# Code\n```\nclass Solution {\n    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {\n// apporoach 1-------------------------------        \n         List<Boolean> list=new ArrayList<>();  \n        for(int i=0; i<l.length; i++)\n        {\n            List<Integer> temp = new ArrayList<>(); \n            for(int j=l[i]; j<=r[i]; j++)\n              { temp.add(nums[j]);}\n               Collections.sort(temp);  \n            int flag=0;\n               for(int j=0;j<temp.size()-1;j++)\n                  {  if(temp.get(j+1)-temp.get(j) != temp.get(1)-temp.get(0))    {flag=1;}  }\n            if(flag==0)  {list.add(true);}\n            else    {list.add(false);}\n        }\n       return list;\n\n//approch 2-----------------\n         List<Boolean> an = new ArrayList<>(); \n         for(int i = 0; i<l.length;i++)\n            {\n            int[] arr = Arrays.copyOfRange(nums,l[i],r[i]+1);\n            Arrays.sort(arr);\n            int flag=0;\n                 for(int j=0; j<arr.length-1; j++)\n                       {   if(arr[j+1]-arr[j] != arr[1]-arr[0]) {flag=1;};    }   \n             if(flag==0)   {an.add(true);} \n              else    {an.add(false);}\n            }\n        return an;\n    }\n}\n
['Java']