0
点赞
收藏
分享

微信扫一扫

【Leetcode_easy】1051. Height Checker

骨灰级搬砖工 2022-07-12 阅读 203

problem

​​1051. Height Checker​​

solution

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

 

参考

1. ​​Leetcode_easy_1051. Height Checker​​;

举报

相关推荐

0 条评论