class Solution { public: int hammingWeight(uint32_t n) { string aaa = toBinary(n); in count = 0; for(int i = 0; i < sizeof(aaa); i++) { if(aaa[i] == "1") count++; } return count; } string toBinary(unsigned int val) { string aaa = ""; for(int i = 16; i >= 0; i--) { if(val & (1 << i)) aaa += "1"; else aaa += "0"; } return aaa; } };