-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/counting-bits
It's more of a question.
For a solution like this:
public class Solution { public int[] countBits(int n) { int[] res = new int[n + 1]; for (int num = 1; num <= n; num++) { for (int i = 0; i < 32; i++) { if ((num & (1 << i)) != 0) { res[num]++; } } } return res; } }
Why is the inner loop treated as O(logN) when n is always an integer and the bit length is always 32?
Shouldn't it be O(1)?
Metadata
Metadata
Assignees
Labels
No labels