Java Solution easy to unterstand!


  • 0
    L

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


Log in to reply
 

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