Finding Hamming Distance

Example 1

x = 9
y = 5
2
class Solution: 
def solve(self, x, y):
ans = 0
while x or y:
ans += (x & 1) ^ (y & 1) x >>= 1 y >>= 1
return ans

--

--

--

Lead, Product Development, Embedded System Specialist/Mad scientist

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Win a chance to grab $20!Home Rebuilding Version 1.0 starts its global open beta

Kislay’s Newsletter (Ep. 9)

Think before you code…

Development unWrapped

Expanding/Replacing a ZFS drive vDev on ZFS on Linux

Deploy Your Stock Trading Algorithms to the Cloud

Tips on passing the Lightning Experience Reports & Dashboards Specialist on Trailhead

∆**Break and Continue statement in java**∆

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Iqram Ali

Iqram Ali

Lead, Product Development, Embedded System Specialist/Mad scientist

More from Medium

Failure to Topper: These 5 Things Made Graduating With a Computer Science Engineering Degree — Easy

CS373 Spring 2022: Mar 28-Apr 3

What Is Object-Oriented Programming? Understanding The Basics

Huffman coding and huffmandict.m in MATLAB