출처 : https://leetcode.com/problems/arithmetic-subarrays/


class Solution {
public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {
List<Boolean> arrayList = new ArrayList<>();
List<Integer> sub = new ArrayList<>();
for (int i = 0; i < l.length; i++) {
boolean flag = true;
for (int n = l[i]; n <= r[i]; n++) {
sub.add(nums[n]);
}
Collections.sort(sub);
for (int m = 0; m < sub.size() - 1; m++) {
if ((sub.get(m + 1) - sub.get(m)) != (sub.get(1) - sub.get(0))) {
arrayList.add(false);
flag = false;
break;
}
}
if (flag) arrayList.add(true);
sub.clear();
}
return arrayList;
}
}