https://practice.geeksforgeeks.org/problems/count-total-set-bits-1587115620/1#
int Count(int n){ int count = 0; while(n){ n = n & (n - 1); count++; } return count; } int countSetBits(int n) { if(n == 0) return 0; else{ return Count(n) + countSetBits(n-1); } // Your logic here }
2.1m questions
2.1m answers
63 comments
56.6k users