Skip to content

Commit 77953bc

Browse files
authored
Create Solution.java
1 parent 224b7dd commit 77953bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int heightChecker(int[] heights) {
3+
int[] copy = Arrays.copyOf(heights, heights.length);
4+
Arrays.sort(copy);
5+
int res = 0;
6+
for (int i = 0; i < heights.length; ++i) {
7+
if (heights[i] != copy[i]) {
8+
++res;
9+
}
10+
}
11+
return res;
12+
}
13+
}

0 commit comments

Comments
 (0)