题目
 
 
 
 
 
 
 
 
 
代码部分(Python 68ms 52.52%)
 
class Solution:
    def heightChecker(self, heights: List[int]) -> int:
        tmp = sorted(heights)
        return sum(tmp[i] != heights[i] for i in range(len(heights))) 
 
 
 
 
 
 
代码部分(Java 2ms 99.21%)
 
class Solution {
    public int heightChecker(int[] heights) {
        int res = 0;
        int[] nums = new int[heights.length];
        System.arraycopy(heights, 0, nums, 0, heights.length);
        
        Arrays.sort(nums);
        for(int i = 0; i < nums.length; i++){
            if(nums[i] != heights[i]) res++;
        }
        
        return res;
    }
}