๐Ÿ“ฆ Adib234 / Leetcode

๐Ÿ“„ height_checker.py ยท 9 lines
1
2
3
4
5
6
7
8
9class Solution:
    def heightChecker(self, heights: List[int]) -> int:
        a = sorted(heights)
        diff = 0
        for i in range(len(a)):
            if a[i] != heights[i]:
                diff += 1
        return diff