😎🚀 Beginner Friendly | Easy To Understand | C++ | JAVA | PYTHON 🦅🚩
Intuition\nUpvote if you found this helpful!!\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving th
# Intuition\nUpvote if you found this helpful!!\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool valid(vector<int>& temp)\n    {\n        int n = temp.size();\n        int diff = temp[1] - temp[0];\n\n        for(int i = 0; i < n - 1; i++)\n        {\n            if(temp[i+1] - temp[i] != diff) \n                return false;\n        }\n        return true;\n    }\n    vector<bool> checkArithmeticSubarrays(vector<int>& nums, vector<int>& l, vector<int>& r) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n        \n        vector<bool> ans;\n\n        for(int i = 0; i < l.size(); i++)\n        {\n            vector<int> temp;\n            int st = l[i], end = r[i];\n            for(int j = st; j <= end; j++)\n            {\n                temp.push_back(nums[j]);\n            }\n            sort(temp.begin(),temp.end());\n            if(valid(temp)) ans.push_back(true);\n            else ans.push_back(false);\n        }\n        return ans;\n    }\n};\n```
['Array', 'C', 'Sorting', 'Python', 'C++', 'Java', 'JavaScript']