-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
binaryBlind 75 - Binary problemsBlind 75 - Binary problemsblind-75Blind 75 - Blind-75 problemsBlind 75 - Blind-75 problems
Description
LeetCode 338: Counting Bits
Category: Binary
Difficulty: See LeetCode
Solution File: src/binary/counting_bits.py
Test File: tests/test_counting_bits.py
Problem Description
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n),
ans[i] is the number of 1's in the binary representation of i.
Example 1:
Input: n = 2
Output: [0,1,1]
Example 2:
Input: n = 5
Output: [0,1,1,2,1,2]
Constraints:
- 0 <= n <= 10^5
Tasks
- Implement the solution in
src/binary/counting_bits.py - Ensure all test cases pass
- Analyze time complexity
- Analyze space complexity
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
binaryBlind 75 - Binary problemsBlind 75 - Binary problemsblind-75Blind 75 - Blind-75 problemsBlind 75 - Blind-75 problems