当前位置:网站首页>剑指 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;
}
};
边栏推荐
- kustomize entry example and basic syntax instructions
- 面试题精选:神奇的斐波那契数列
- 十进制数字→十六进制字符
- 自定义VIEW实现应用内消息提醒上下轮播
- 农村区县域农业电商如何做?数字化转型如何进行?
- About the handling of variable parameters in the Retrofit network request URL
- Flutter入门进阶之旅(二)Hello Flutter
- Unicom network management protocol block diagram
- Flutter Getting Started and Advanced Tour (1) - Getting to Know Flutter
- 陈强教授《机器学习及R应用》课程 第十六章作业
猜你喜欢

How to save Simulink simulation model as image or PDF

Unicom network management protocol block diagram

Report: The number of students who want to learn AI has increased by 200%, and there are not enough teachers

Data Mining-05

新起之秀 DPU,正在掀起数据中心变革!

Rust从入门到精通04-数据类型

Go Affair, How to Become a Gopher and Find a Go Job in 7 Days, Part 1

How to reduce the size of desktop icons after the computer is reinstalled

工作任务统计

Ten minutes to teach you how to use VitePress to build and deploy a personal blog site
随机推荐
Go 事,如何成为一个Gopher ,并在7天找到 Go 语言相关工作,第1篇
ansible-cmdb friendly display ansible collects host information
GIN中GET POST PUT DELETE请求
用场景定义硬件,英码科技破解“边缘计算”密码
阿里大淘系模型治理阶段性分享
Periodic sharing of Alibaba Da Tao system model governance
我的2020年终总结
Flutter Getting Started and Advanced Tour (3) Text Widgets
Flutter入门进阶之旅(八)Button Widget
十进制数字→十六进制字符
WSA toolkit installed app store tip doesn't work how to solve?
Do you know the difference between comments, keywords, and identifiers?
jenkins api create custom pipeline
Redis源码剖析之robj(redisObject)
5G China unicom 一般性异常处理
jenkins api创建自定义pipeline
Report: The number of students who want to learn AI has increased by 200%, and there are not enough teachers
卷积神经网络表征可视化研究综述(1)
在已打开图片上加水印(文字)
造自己的芯,让谷歌买单!谷歌再度开源 180nm 工艺的芯片