当前位置:网站首页>剑指offer基础版 --- 第22天
剑指offer基础版 --- 第22天
2022-07-31 05:09:00 【米兰的小红黑】

class Solution {
public int[] singleNumbers(int[] nums) {
int ret = 0;
for(int num : nums){
ret = ret ^ num;
}
int target = 1;
while((target & ret) == 0){
target = target << 1;
}
int a = 0;
int b = 0;
for(int num : nums){
if((num & target) == 0){
a = a ^ num;
}else{
b = b ^ num;
}
}
return new int[]{
a,b};
}
}

class Solution {
public int singleNumber(int[] nums) {
int[] counts = new int[32];
for(int num : nums) {
for(int j = 0; j < 32; j++) {
counts[j] += num & 1;
num >>>= 1;
}
}
int res = 0, m = 3;
for(int i = 0; i < 32; i++) {
res = (counts[i] % m) << i | res;
}
return res;
}
}
边栏推荐
- STM32 - DMA
- Redis Advanced - Cache Issues: Consistency, Penetration, Penetration, Avalanche, Pollution, etc.
- <urlopen error [Errno 11001] getaddrinfo failed>的解决、isinstance()函数初略介绍
- MySQL (updating)
- 账号或密码多次输入错误,进行账号封禁
- Temporal对比Cadence
- 关于superset集成到自己的项目中
- MySQL optimization slow log query
- DVWA shooting range environment construction
- C语言教程(二)-printf及c自带的数据类型
猜你喜欢

Moment Pool Cloud quickly installs packages such as torch-sparse and torch-geometric

Unity resources management series: Unity framework how to resource management

12个MySQL慢查询的原因分析
![[MQ I can speak for an hour]](/img/ef/863c994ac3a7de157bd39545218558.jpg)
[MQ I can speak for an hour]

DVWA installation tutorial (understand what you don't understand · in detail)

mysql uses on duplicate key update to update data in batches

剑指offer专项突击版 --- 第 3 天

面试官问我TCP三次握手和四次挥手,我真的是

MySQL (updating)

如何将项目部署到服务器上(全套教程)
随机推荐
mysql stored procedure
Interview Redis High Reliability | Master-Slave Mode, Sentinel Mode, Cluster Cluster Mode
mysql5.7.35安装配置教程【超级详细安装教程】
Sql解析转换之JSqlParse完整介绍
centos7安装mysql5.7
mysql 的简单运用命令
pytorch中的一维、二维、三维卷积操作
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
A complete introduction to JSqlParse of Sql parsing and conversion
DVWA installation tutorial (understand what you don't understand · in detail)
datagrip带参sql查询
matlab simulink欠驱动水面船舶航迹自抗扰控制研究
Temporal客户端模型
MySQL8.0.26安装配置教程(windows 64位)
With MVC, why DDD?
110道 MySQL面试题及答案 (持续更新)
基于web3.0使用钱包Metamask的三方登陆
Summary of MySQL common interview questions (recommended collection!!!)
Unity mobile game performance optimization series: performance tuning for the CPU side
DVWA靶场环境搭建