96. count "1" in binary form
Share
easy - accepted / - tried
Given an integer, count "1" in its binary form.
countOne(1) // 1, "1"countOne(257799) // 12, "111110111100000111"
- If you use built-in string methods in JavaScript, please do understand the time complexity, they are not free.
- Actually this could be easily done by counting the digit one by one. Could you think of some other approaches?