728x90
정렬한 리스트와 기존 리스트가 다른 숫자를 count하는 문제
class Solution:
def heightChecker(self, heights: List[int]) -> int:
heig = sorted(heights)
a = 0
for i in range(len(heig)):
if heights[i] != heig[i]:
a += 1
return a
sorted한 리스트와 비교해서 a를 1씩 올려줌
Runtime : 0ms
Memory : 17.94MB (6.58%)
728x90
'코딩 공부 > Leetcode' 카테고리의 다른 글
[Python] 448. Find All Numbers Disappeared in an Array (0) | 2025.02.02 |
---|---|
[Python] 414. Third Maximum Number (0) | 2025.02.01 |
[Python] 905. Sort Array By Parity (0) | 2025.01.30 |
[Python] 283. Move Zeroes (0) | 2025.01.29 |
[Python] 1299. Replace Elements with Greatest Element on Right Side (0) | 2025.01.28 |