首页 > 其他 > 详细

汉明距离

时间:2017-05-02 22:50:45      阅读:249      评论:0      收藏:0      [点我收藏+]

public class Solution {
  public int hammingDistance(int x, int y) {
  return Integer.bitCount(x ^ y);
  }
}

 

bitCount api  :

static int bitCount(int i)
Returns the number of one-bits in the two‘s complement binary representation of the specified int value.

返回指定int值的二进制补码二进制表示中的一位数。

汉明距离

原文:http://www.cnblogs.com/yinfj/p/6798896.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!