문제 1️⃣ (리트코드_비트 세기)
https://leetcode.com/problems/counting-bits/description/
💡 IDEA : Integer 내부 함수인 bitCount(int i) 를 사용한다.

class Solution {
public int[] countBits(int n) {
int[] answer = new int[n+1];
for (int i=1; i<=n; i++) {
answer[i] = Integer.bitCount(i);
}
return answer;
}
}
'TIL 📔' 카테고리의 다른 글
| TIL (2024.06.11) _ (Programmers) 입국 심사 (0) | 2024.06.11 |
|---|---|
| TIL (2024.06.08) (1) | 2024.06.09 |
| TIL (2024.06.05) (1) | 2024.06.05 |
| TIL 24일차 (2022.01.05) (0) | 2023.01.05 |
| TIL 23일차 (2022.12.29) (0) | 2023.01.02 |