位运算

  1. 汉明距离(与运算):https://leetcode-cn.com/problems/hamming-distance/

  2. 只出现1次的数(异或抵消):https://leetcode-cn.com/problems/single-number/submissions/

    class Solution {
     public int singleNumber(int[] nums) {
         //异或:相同则0,不同则本身。只出现一次的数字无法被相消
         int result = 0;
         for(int i : nums){
             result ^= i;
         }
         return result;
     }
    }
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 10:56
点赞 评论 收藏
分享
Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务