
338. Counting Bits
·
Algorithm
Counting Bits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 내장 함수를 이용한 탐색 def countBits(self, num: int) -> List[int]: answer = [] for i in range(num + 1): answer.append(format(i, "b").count("1")) return answer 2. 비트의 성질을 이용한 반복 사용 def countBits(self, num: int) -> List[int]: ..