Simple solution || Begineer Friendly || 100% Beats || Easy to understand
Intuition\n Describe your first thoughts on how to solve this problem. \nTaking subArray from the given left and right array. Sort the array and then check diff
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTaking subArray from the given left and right array. Sort the array and then check difference for all consecutives element.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.check function: Sorts the given array and checks if the elements form an arithmetic sequence by verifying if the difference between consecutive elements remains constant.\n2.checkArithmeticSubarrays function: Loops through the provided ranges l and r to extract subarrays from nums, then checks each subarray using the check function to determine if they form arithmetic sequences.\n3.ans vector: Stores the boolean results indicating whether each subarray is an arithmetic sequence or not.\n4.Return: Returns the vector containing results for each subarray\'s arithmetic sequence check.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nTime complexity:\n  O(m\u22C5n\u22C5logn)\n- Space complexity:\n- O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {\n        ArrayList<Boolean> list=new ArrayList<>();\n        int n=l.length;\n        for(int i=0;i<n;i++){\n           int len=r[i]-l[i]+1;\n           int k=0;\n            int a[]=new int[len];\n            for(int j=l[i];j<=r[i];j++){\n                a[k]=nums[j];\n                k++;\n            }\n            Arrays.sort(a);\n            int t=0;\n            int d=a[1]-a[0];\n            for(int p=0;p<a.length-1;p++){\n              \n                if(a[p+1]-a[p]!=d){\n                    t++;\n                    //list.add(false);\n                    break;\n                }\n            }\n            if(t==0)\n            list.add(true);\n            else\n            list.add(false);\n        }\n        return list;\n    }\n}\n```
['Java']