骨灰级搬砖工

关注

【Leetcode_easy】1051. Height Checker

骨灰级搬砖工

关注

阅读 203

2022-07-12

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​​;

完

相关推荐

小迁不秃头

LeetCode --- 1051. Height Checker 解题报告

小迁不秃头 103 0 0

_铁马冰河_

2019-12-31-LeetCode【1051. 高度检查器】

_铁马冰河_ 54 0 0

软件共享软件

【Leetcode_easy】690. Employee Importance

软件共享软件 92 0 0

王小沫

【Leetcode_easy】706. Design HashMap

王小沫 112 0 0

舟海君

【leetcode_easy】299. Bulls and Cows

舟海君 159 0 0

雅典娜的棒槌

【Leetcode_easy】867. Transpose Matrix

雅典娜的棒槌 93 0 0

小铺有酒一两不够

【Leetcode_easy】645. Set Mismatch

小铺有酒一两不够 82 0 0

90哦吼

【Leetcode_easy】704. Binary Search

90哦吼 86 0 0

流计算Alink

【Leetcode_easy】697. Degree of an Array

流计算Alink 53 0 0

转角一扇门

【Leetcode_easy】709. To Lower Case

转角一扇门 63 0 0

精彩评论(0)

0 0 举报