update the leetcode problem

This commit is contained in:
Jidong Xiao
2023-09-07 22:35:34 -04:00
parent 10ee772a1f
commit 47b932e9ed
2 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
class Solution {
public:
int heightChecker(vector<int>& heights) {
int count = 0;
int size = heights.size();
vector<int> expected(heights);
sort(expected.begin(),expected.end());
for(int i=0;i<size;i++){
if(heights[i]!=expected[i]){
count++;
}
}
return count;
}
};