Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-09_01-19-45.png
29.1 KB
#N1502. Can Make Arithmetic Progression From Sequence
problem link

#solution
class Solution {
public boolean canMakeArithmeticProgression(int[] arr) {
Arrays.sort(arr);

for(int i=0; i<arr.length-2; i++){
if(arr[i]+arr[i+2]!=2*arr[i+1])
return false;
}

return true;
}
}