(int n)
| 66 | |
| 67 | //a faster method to count set bits |
| 68 | public static int countSetBits2(int n) { |
| 69 | int setBits = 0; |
| 70 | while(n>0) { |
| 71 | // removes the last set bit from curr number |
| 72 | n = n & (n-1); |
| 73 | setBits++; |
| 74 | } |
| 75 | return setBits; |
| 76 | } |
| 77 | public static void main(String args[]) { |
| 78 | System.out.println(countSetBits(9)); |
| 79 | } |
nothing calls this directly
no outgoing calls
no test coverage detected