In this video I explain the algorithm behind solving Leetcode problem #191 Number of 1 Bits. The concept of this problem can be used to solve #477 Hamming Distance ( • Explaining Leetcode #477 Total Hamming Dis... ) and #461 Hamming Distance. In fact, the algorithm here resembles Java's Integer.bitCount()
I am coding in Java since its syntax is easy to understand by all programmers. The algorithms can be applied easily in other languages and most functions that I use have a counterpart in your language of choice.
0:00 Explaining the concept behind the problem.
2:46 Starting to code
4:32 Shifting bits
Related Topics: Bit Manipulation