My Accepted Java Solution


  • 0
    D
        public class Solution {
           public int hammingDistance(int x, int y) {
             int count=0;
             int b = x^y;
             for(int i=0;i<32;i++)
             {
           
                if((b&(1<<i))!=0)
               {
                   count++; 
               }
            
         }
          return count;
        
    }
    

    }


Log in to reply
 

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