3 lines Java Solution


  • 0
    G

    use bitcount() method:

    int[] test = new int[num+1];
    for(int i = 0; i <= num; i++) test[i] = Integer.bitCount(i);
    return test;


Log in to reply
 

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