[4ms solution] A simple DP solution with JAVA that can solve input num up to 1100000 within 6ms

  • 0

    Here is my solution, but it cannot run with num what is too large.

    public class Solution {
        public int[] countBits(int num) {
            int[] result = new int[num+1];
            for(int i=0; i<result.length;i++){
                result[i]=(i&1)+result[i >>> 1];
            return result;

Log in to reply

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