1 Star 0 Fork 0

Roderland/algorithm

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Question260.java 587 Bytes
一键复制 编辑 原始数据 按行查看 历史
Roderland 提交于 2021-03-19 00:37 +08:00 . ====== roderland ======
package question;
/**
* @author Roderland
* @since 1.0
*/
public class Question260 {
public static void main(String[] args) {
System.out.println(Integer.lowestOneBit(9));
}
public int[] singleNumber(int[] nums) {
int tmp=0;
for (int num : nums) {
tmp^=num;
}
int a=0;
int b=0;
int x=Integer.lowestOneBit(tmp);
for (int num : nums) {
if ((num&x)==0) {
a^=num;
} else {
b^=num;
}
}
return new int[]{a,b};
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/Roderland/algorithm.git
git@gitee.com:Roderland/algorithm.git
Roderland
algorithm
algorithm
master

搜索帮助