본문 바로가기
python-algorithm

leetcode 1051. Height Checker

by 무적김두칠 2022. 3. 21.

1
2
3
4
5
6
7
class Solution:
    def heightChecker(self, heights: List[int]) -> int:
        compare=sorted(heights)
        ans=0
        for i in range(len(heights)):
            if heights[i]!= compare[i]: ans+=1
        return ans
cs
반응형

댓글