class Solution { public boolean canMakeArithmeticProgression(int[] arr) { Arrays.sort(arr); int d = arr[1] - arr[0]; int a = arr[0]; for(int i =2 ;i < arr.length;i++) if(arr[i] != (a + i*d)) return false; return true; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter