首页 > 其他 > 详细

leetcode461 汉明距离

时间:2018-12-11 19:22:35      阅读:148      评论:0      收藏:0      [点我收藏+]

对数的与,异或操作

 int hammingDistance(int x, int y) {
    int res=0;
    int z=x^y;//得到两个数的不同位置
    while(z!=0)
    {
      res++;
      z&=(z-1);    
    }
return res;
}
    

 

leetcode461 汉明距离

原文:https://www.cnblogs.com/biubiuWham/p/10104218.html

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