update the leetcode problem
This commit is contained in:
15
leetcode/p1051_heightchecker.cpp
Normal file
15
leetcode/p1051_heightchecker.cpp
Normal 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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user