Explaining Leetcode

Опубликовано: 31 Март 2026
на канале: JTECH
99
1

In this video I explain the algorithm behind solving Leetcode problem #461 Hamming Distance. I will detail an algorithm to execute the task 'manually', and then use functions that achieve it directly.

I used here Java's Integer.bitCount()function to count the number of ones, in video "#191 Number of 1 Bits" (   • Explaining Leetcode #191 Number of 1 Bits ...  ) I explain how this function works in case you want to implement it manually.

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.

00:00 I start by explaining the long algorithm that is suitable for newbies.
10:41 I resolve the problem using bit level (XOR) operations resulting in a shorter program.
15:10 I optimize this program furthermore.

Related Topics: Bit Manipulation