Unknown's avatar

1051. Height Checker

1051. Height Checker

class Solution {
    public int heightChecker(int[] heights) {
        int[] original = new int[heights.length];
    	original = heights.clone();
    	Arrays.sort(heights);
    	int count = 0;
    	for (int i = 0; i < heights.length; i++) {
    		if (heights[i] != original[i])count++;
    	}
    	return count;
    }
}

 

Leave a comment