位运算
文章平均质量分 81
xiaocong1990
这个作者很懒,什么都没留下…
展开
-
[leetcode]只出现一次的数字Ⅲ
找出只出现一次的那两个元素。-3的反码: 11111111 11111111 11111111 11111100(原码的符号位不变,其他位按位取反)如:3: 00000000 00000000 00000000 00000011(整数的原码,反码,补码都相同)(这两个数字互不相同,则一定在某些二进制位上,一个数字是1,另一个数字则对应是0)异或的结果,它所有的二进制位中一定存在二进制位为1的,此位置的二进制位就可以区分。数字&(-数字):可以得到此数字二进制位中最低位的1,这里称之为j。原创 2024-04-09 11:15:49 · 631 阅读 · 0 评论 -
[leetcode]476. Number Complement
题目链接:https://leetcode.com/problems/number-complement/#/descriptionGiven a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representati原创 2017-07-11 15:04:26 · 257 阅读 · 0 评论 -
[leetcode]260. Single Number III
链接:https://leetcode.com/problems/single-number-iii/description/Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find th...原创 2018-09-01 14:09:07 · 100 阅读 · 0 评论 -
[leetcode]136. Single Number
链接:https://leetcode.com/problems/single-number/description/Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a...原创 2018-09-01 14:10:59 · 97 阅读 · 0 评论 -
[leetcode]137. Single Number II
链接:https://leetcode.com/problems/single-number-ii/description/ Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single o...原创 2018-09-01 14:12:06 · 95 阅读 · 0 评论