class Solution {
public:
int heightChecker(vector<int>& heights) {
vector<int> oriheights = heights;
sort(heights.begin(),heights.end());
// cmp difference
int count = 0;
for(int i=0;i<heights.size();i++){
if (oriheights[i]!=heights[i]){
count++;
}
}
return count;
}
};
1051. Height Checker
最新推荐文章于 2024-07-11 23:32:17 发布