Beats 100%🔥|| easy JAVA Solution✅
1st Method(Without Sorting)\n\nclass Solution {\n    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {\n        List<Boolean> ans=ne
# 1st Method(Without Sorting)\n```\nclass Solution {\n    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {\n        List<Boolean> ans=new ArrayList();\n        for(int i=0;i<l.length;i++){\n            ans.add(sol(nums,l[i],r[i]));\n        }\n        return ans;\n    }\n    public boolean sol(int[] nums,int l,int r){\n        int min=Integer.MAX_VALUE,max=Integer.MIN_VALUE;\n        for(int i=l;i<=r;i++){\n            min=Math.min(min,nums[i]);\n            max=Math.max(max,nums[i]);\n        }\n        int len=r-l+1;\n        if((max-min)%(len-1)!=0) return false;\n        int d=(max-min)/(len-1);\n        if(d==0) return true;\n        boolean[] arr=new boolean[len];\n        for(int i=l;i<=r;i++){\n            if((nums[i]-min)%d!=0) return false;\n            else{\n                int idx=(nums[i]-min)/d;\n                if(arr[idx]) return false;\n                arr[idx]=true;\n            }\n        }\n        return true;\n    }\n}\n```\n# 2nd Method (Sorting)\n```\nclass Solution {\n    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {\n        List<Boolean> ans=new ArrayList();\n        for(int i=0;i<l.length;i++){\n            int arr[]=new int[r[i]-l[i]+1];\n            int k=0;\n            for(int j=l[i];j<=r[i];j++){\n                arr[k++]=nums[j];\n            }\n            ans.add(sol(arr));\n        }\n        return ans;\n    }\n    public boolean sol(int[] arr){\n        if(arr.length==1) return true;\n        Arrays.sort(arr);\n        int d=arr[1]-arr[0];\n        for(int i=2;i<arr.length;i++){\n            if(arr[i]-arr[i-1]!=d) return false;\n        }\n        return true;\n    }\n}\n```
['Java']