4ms Java solution


  • -1
    T
    public class Solution {
        public int[] countBits(int num) {
            int nums[] = new int[num + 1];
            for (int i=0; i <= num;i++)
            {
                nums[i] = Integer.bitCount(i);
            }
            return nums;
            
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.