class Solution {
public List
int n = l.length;
List
for (int i = 0; i < n; ++i) {
int left = l[i], right = r[i];
int minv = nums[left], maxv = nums[left];
for (int j = left + 1; j <= right; ++j) {
minv = Math.min(minv, nums[j]);
maxv = Math.max(maxv, nums[j]);
}
if (minv == maxv) {
ans.add(true);
continue;
}
if ((maxv - minv) % (right - left) != 0) {
ans.add(false);
continue;
}
int d = (maxv - minv) / (right - left);
boolean flag = true;
boolean[] seen = new boolean[right - left + 1];
for (int j = left; j <= right; ++j) {
if ((nums[j] - minv) % d != 0) {
flag = false;
break;
}
int t = (nums[j] - minv) / d;
if (seen[t]) {
flag = false;
break;
}
seen[t] = true;
}
ans.add(flag);
}
return ans;
}
}
标签:1630,right,nums,int,maxv,数组,差子,minv,left From: https://www.cnblogs.com/rickierun/p/17249783.html