Leetcode 338. Counting Bits
Return an array of the number of 1-bits (popcount) for every integer from 0 to n, with the challenge to compute all counts in O(n) time and a single pass without using built-in popcount functions, typically by exploiting bit-DP relations like dp[i] = dp[i & (i-1)] + 1 or dp[i>>1] + (i&1).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Your account is free and you can post anonymously if you choose.