Skip to content

Commit f1a9c8f

Browse files
authored
Create arithmeticProgression.java
1 parent 19cf890 commit f1a9c8f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arithmeticProgression.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/
2+
3+
class arithmeticProgression {
4+
public boolean canMakeArithmeticProgression(int[] arr) {
5+
Arrays.sort(arr);
6+
int difference = arr[1] - arr[0];
7+
for (int i = 2 ; i <= arr.length - 1 ; i++) {
8+
if ((arr[i] - arr[i - 1]) != difference)
9+
return false;
10+
}
11+
return true;
12+
}
13+
}

0 commit comments

Comments
 (0)