class Solution {
public int heightChecker(int[] heights) {
int length = heights.length;
int num = 0;
int[] expected = new int[length];
System.arraycopy(heights,0,expected,0,length);
Arrays.sort(heights);
for(int i=0;i<heights.length;i++){
if(heights[i] != expected[i]){
num++;
}
}
return num;
}
}
1051. 高度检查器
最新推荐文章于 2024-11-10 21:54:30 发布