Integer.bitCount


  • 0
    T

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


Log in to reply
 

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