Question

LeetCode #461

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

Given two integers x and y, calculate the Hamming distance.

Pseudo code

  1. convert integers to binary strings
  2. get the biggest length of converted strings
  3. create padding to fill missing digits
  4. fill short string with padding to make two strings even in length, then convert to array
  5. compare each member and count the distance

Playground

See the Pen #461 Hamming distance by Cherry Wang (@chryw) on CodePen.