Understandable java solution


  • 0
    A
    public class Solution {
        public int hammingDistance(int x, int y) {
            int count=0,i=0;
            while(i<32){
                if((x&1)%10!=(y&1)%10) count++;
                x=x>>1;
                y=y>>1;
                i++;
            }
            return count;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.