Back to QuestionsPractice with This Question
Counting Bits
48.9K views•Asked at Amazon•
Medium
Question Explain
Given an integer $n$, return an array `ans` of length $n+1$ such that for each $i$ ($0 \leq i \leq n$), `ans[i]` is the number of 1's in the binary representation of $i$. Solve in $O(n)$ time using DP/Bit Manipulation.
Start Trying This Question Simulation
Practice answering orally or with text to get instant AI feedback.