An easy and understandable solution to the given problem
Intuition\nThe problem asks to check whether each subarray specified by the given left and right indices forms an arithmetic sequence. An arithmetic sequence is
# Intuition\nThe problem asks to check whether each subarray specified by the given left and right indices forms an arithmetic sequence. An arithmetic sequence is a sequence of numbers in which the difference of any two successive members is a constant.\n\n# Approach\n1. For each subarray specified by the left and right indices, extract the subarray from the original array.\n2. Sort the subarray to make it easier to check if it forms an arithmetic sequence.\n3. Calculate the common difference (t) between adjacent elements in the sorted subarray.\n4. Check if all differences are equal. If they are, the subarray forms an arithmetic sequence.\n5. Store the result for each subarray in a vector and return the vector of boolean values.\n\n# Complexity\n\n- Time complexity: \n1. Extracting subarrays for each query takes O(N) time, where N is the size of the input array.\n2. Sorting each subarray takes O(M log M) time, where M is the size of the subarray.\n3. Checking if the subarray forms an arithmetic sequence takes O(M) time.\n4. The overall time complexity is O(Q * (N + M log M)), where Q is the number of queries. \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n1. The space complexity is dominated by the sorted subarray, which takes O(M) space.\n2. Additionally, the space used by other variables is constant.\n3. The overall space complexity is O(M).\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#include <algorithm>\n#include <iostream>\n#include <vector>\nclass Solution {\npublic:\n    vector<bool> checkArithmeticSubarrays(vector<int>& n, vector<int>& l, vector<int>& r) \n    {\n        vector<bool> res;\n        for(int i = 0;i<l.size();i++)\n        {\n            vector<int> s(n.begin() +l[i],n.begin() + (r[i]+1));\n            sort(s.begin() ,s.end());\n            int t = s[1]-s[0];\n            bool seq = true;\n            for(int j = 1;j<s.size()-1;j++)\n            {\n                int t1 = s[j+1]-s[j];\n                if(t!=t1)\n                {\n                    seq = false;\n                    break;\n                }\n            }\n            res.push_back(seq);\n        }\n        return res;    \n    }\n};\n```
['C++']