当前位置:网站首页>剑指 Offer 56 - II. 数组中数字出现的次数 II(位运算)
剑指 Offer 56 - II. 数组中数字出现的次数 II(位运算)
2022-08-09 12:45:00 【养猪去】
class Solution {
public:
int singleNumber(vector<int>& nums) {
int cnt[32] = {
0};
for(int x : nums) {
for(int i = 0; i < 32; i++) {
cnt[i] += (x >> i) & 1;
}
}
int ans = 0;
for(int i = 0; i < 32; i++) {
if(cnt[i] % 3) {
ans |= 1 << i;
}
}
return ans;
}
};
边栏推荐
- Extract EventBus encapsulation to base class using annotations
- Standing wave ratio calculation method
- novel research
- 透明tune proxy
- 数据挖掘-06
- Redis源码剖析之字典(dict)
- 大佬们,请教一下,我看官方文档中,sqlserver cdc只支持2012版之后的,对于sqlser
- ViewPager fragments of nested data blank page abnormal problem analysis
- Rust从入门到精通04-数据类型
- Yocto 可以下载的第三方库
猜你喜欢
阿里大淘系模型治理阶段性分享
K个结点的组内逆序调整
Redis源码剖析之字典(dict)
注:检测到当前使用的ADB不是HBuilder内置或自定义ADB:PID为:9544进程名称为:adb.exe 路径为:c:\users\administrator\appdata\local\and
【HCIP持续更新】IS-IS协议原理与配置
Redis源码剖析之跳表(skiplist)
Go 事,如何成为一个Gopher ,并在7天找到 Go 语言相关工作,第1篇
How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
kustomize entry example and basic syntax instructions
面试题精选:神奇的斐波那契数列
随机推荐
Flutter Getting Started and Advanced Tour (3) Text Widgets
5G China unicom AP:B SMS ASCII Transcoding Requirements
NFS 特别注意权限的问题
阿里大淘系模型治理阶段性分享
Rust从入门到精通04-数据类型
Extract EventBus encapsulation to base class using annotations
Rust from entry to proficient 04 - data types
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
陈强教授《机器学习及R应用》课程 第十六章作业
自定义VIEW实现应用内消息提醒上下轮播
使用注解将EventBus封装抽取到基类
注:检测到当前使用的ADB不是HBuilder内置或自定义ADB:PID为:9544进程名称为:adb.exe 路径为:c:\users\administrator\appdata\local\and
Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目
Redis源码剖析之字典(dict)
WebView injects Js code to realize large image adaptive screen click image preview details
LnReader编译
Yocto 可以下载的第三方库
WSA工具箱安装应用商店提示无法工作怎么解决?
Go 事,如何成为一个Gopher ,并在7天找到 Go 语言相关工作,第1篇
5G Unicom Network Management Design Ideas