Arithmetic Subarrays
\nThis code shows index  out of range error for some and works for the rest. I\'m not able to understand how the error is coming.\n\n\n\nclass Solution {\n    p
\nThis code shows index  out of range error for some and works for the rest. I\'m not able to understand how the error is coming.\n\n```\n\nclass Solution {\n    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {\n        List<Boolean> an = new ArrayList<Boolean>(Arrays.asList(new Boolean[l.length]));\n        \n        Collections.fill(an,true);\n        for(int i = 1; i<=l.length-1;i++){\n            int[] arr = Arrays.copyOfRange(nums,l[i],r[i]);\n            Arrays.sort(arr);\n            int dp[] = new int[arr.length];\n            for(int j =1;j<=arr.length-1;j++){\n                if((i<=(arr.length-1)))dp[i]=arr[i]-arr[i-1];\n                if(dp[i]!=dp[i-1] && i!=0){\n                    an.set(i,false);break;\n                }\n            }\n            \n        }\n        \n        return an;\n    }\n}\n```
[]