class Solution { public int heightChecker(int[] heights) { int [] tmp = heights.clone(); Arrays.sort(tmp); int result = 0; for(int i = 0; i< heights.length; i++){ if(heights[i]!= tmp[i]){ result ++; } } return result; } }
(Easy) Height Checker LeetCode
原文:https://www.cnblogs.com/codingyangmao/p/11277008.html