Fork me on GitHub

LeetCode之461. Hamming Distance

------------------------------------------------------------------

 

AC代码:

public class Solution {
    public int hammingDistance(int x, int y) {
        return Integer.toString(x^y,2).replaceAll("0","").length();
    }
}

 

 

题目来源: https://leetcode.com/problems/hamming-distance/

 

posted @ 2016-12-31 22:37  CC11001100  阅读(178)  评论(0编辑  收藏  举报