【Leetcode】Single Number II (Bit Manipulation)
来源:互联网 发布:淘宝哪家男装店好 编辑:程序博客网 时间:2024/06/05 20:32
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
具体分析参见位运算之找出奇特的数
直接上代码
public int singleNumber(int[] A) {int[] digit = new int[32];int result = 0;for (int i = 0; i < 32; i++) {for (int j = 0; j < A.length; j++) {digit[i] += (A[j] >> i) & 1;}}for (int i = 0; i < 32; i++)result |= (digit[i] % 3) << i;return result;}
0 0
- 【Leetcode】Single Number II (Bit Manipulation)
- leetcode:Bit Manipulation:Single Number II(137)
- Bit Manipulation Single Number II
- 【Leetcode】Single Number (Bit Manipulation)
- Bit Manipulation - Single Number I, II, III
- [leetcode][bit] Single Number
- Single Number II - leetcode
- Leetcode: Single Number II
- [LeetCode] Single Number II
- LeetCode: Single Number II
- leetcode -- Single Number II
- [leetcode]Single Number II
- [LeetCode] Single Number II
- 【leetcode】Single Number II
- LeetCode:Single Number II
- Leetcode: Single Number II
- leetcode :Single Number II
- Leetcode Single Number II
- methodserver停止前有软件异常,查看详细信息
- 遇到问题:注入 status 属性时、死活进不去action 断点、怀疑是因为status 属性引起的、struts2本身的bug
- Java程序员的JavaScript学习笔记(11——jQuery-在“对象”层面扩展)
- ubuntu 64 运行android sdk 发生错误 "../android-sdks/build-tools/aapt 文件不存在"
- 【Leetcode】Single Number (Bit Manipulation)
- 【Leetcode】Single Number II (Bit Manipulation)
- JAVA 数组,链表,树的基本概念与优劣。
- 开罗解放东路高架的福利国家
- 极限学习机 extreme learning
- 立刻就给了对方进攻的福利及股东
- 命令行创建指定屏幕大小的avd
- 关于gcc的一点小人性化提示
- Valid Parentheses
- [Leetcode] Convert Sorted List to Binary Search Tree Solution