24ms faster than 99% and less space than 90% cpp solution
I have commented at each step for better understanding.\n\n\n    vector<bool> checkArithmeticSubarrays(vector<int>& nums, vector<int>& l, vector<int>& r) {\n   
I have commented at each step for better understanding.\n\n```\n    vector<bool> checkArithmeticSubarrays(vector<int>& nums, vector<int>& l, vector<int>& r) {\n        int n=nums.size(),m=l.size();\n        vector<bool> ans(m);\n        \n        int min1=1000000,max1=-1000000,len=0;\n        int diff=0;\n        \n        long long sum1=0,sum2=0;\n        for(int i=0;i<m;i++){\n            \n            if(r[i]-l[i]==1){\n                ans[i]=true;\n            }\n            \n            else{\n                min1=1000000; max1=-1000000; len=r[i]-l[i]+1;\n                for(int j=l[i];j<=r[i];j++){\n                    min1=min(min1,nums[j]);\n                    max1=max(max1,nums[j]);\n                }\n                \n                diff=(max1-min1)/(len-1);\n                if(max1==min1){    //all elemnts in sequence are same\n                    ans[i]=true;\n                }\n                else if((max1-min1)%(len-1)){  //diff varies in sequence\n                    ans[i]=false;\n                }\n                else{\n                    vector<bool> diffs(len); //storing sequence withindex if valid or not\n                    int j=l[i];\n                  \n                    for(;j<=r[i];j++){\n                        if((nums[j]-min1)%diff){  //diff is diifrent therefore not AP\n                            break;\n                        }\n                        else if(diffs[(nums[j]-min1)/diff]){  //number repeated in sequence so not AP\n                            break;\n                        }\n                        diffs[(nums[j]-min1)/diff]=true; //nums[j]-min1/diff give index of elmnt in AP \n                    }\n                    ans[i]=(j>r[i]);\n                }\n            }\n        }\n        \n        return ans;\n    }\n\t```\n\t
['C++']