-
60. Height CheckerProblem Solving 2023. 1. 9. 00:56728x90
https://leetcode.com/problems/height-checker/
Height Checker - LeetCode
Height Checker - A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected[i] is th
leetcode.com
정렬된 리스트와 원래의 리스트를 비교해서 몇 개의 수가 같은 위치에 있지 않은지 카운트
class Solution: def heightChecker(self, heights: List[int]) -> int: expected = sorted(heights) count = 0 for i in range(len(heights)): if expected[i] != heights[i]: count = count + 1 return count
'Problem Solving' 카테고리의 다른 글
62. 2016년 (0) 2023.01.09 61. Add Binary (0) 2023.01.09 58. 소트인사이드 (0) 2023.01.08 57. Remove All Adjacent Duplicates in String (0) 2023.01.08 56. 스택 (0) 2023.01.08