class Solution { public: int NumberOf1(int n) { int cnt=0; unsigned int k=n; while(k){ if(k&1) cnt++; k>>=1; } return cnt; } };