[LeetCode] Height Checker (Python)
2024. 3. 3. 10:29ㆍ자료구조
class Solution:
def heightChecker(self, heights: List[int]) -> int:
new_h = sorted(heights)
match = 0
for i in range(len(heights)):
if heights[i] != new_h[i]:
match += 1
return match
'자료구조' 카테고리의 다른 글
[LeetCode] Find All Numbers Disappeared in an Array (Python) (0) | 2024.03.03 |
---|---|
[LeetCode] Third Maximum Number (Python) (0) | 2024.03.03 |
[LeetCode] Sort Array By Parity (Python) (0) | 2024.02.29 |
[LeetCode] Move Zeroes (Python) (0) | 2024.02.29 |
[LeetCode] Replace Elements with Greatest Element on Right Side (Python) (0) | 2024.02.29 |