当前位置:网站首页>剑指 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;
}
};
边栏推荐
- Periodic sharing of Alibaba Da Tao system model governance
- Report: The number of students who want to learn AI has increased by 200%, and there are not enough teachers
- 位图与位运算
- 保存Simulink仿真模型为图片或者PDF的方法
- 乐东消防救援大队应邀为干部开展消防安全培训
- WSA工具箱安装应用商店提示无法工作怎么解决?
- Extract EventBus encapsulation to base class using annotations
- 基于 R 语言的判别分析介绍与实践 LDA和QDA
- Flutter Getting Started and Advanced Tour (8) Button Widget
- Data Mining-05
猜你喜欢

Flutter入门进阶之旅(六)Layout Widget

The new features of ABP 6.0.0 - rc. 1

2022年非一线IT行业就业前景?

World's 4th mad scientist dies on his 103rd birthday

Jenkins API groovy calling practice: Jenkins Core Api & Job DSL to create a project

安踏携手华为运动健康共同验证冠军跑鞋 创新引领中国体育

某高校的R语言数据分析期末作业

Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目

Customize VIEW to realize in-app message reminder to rotate up and down

How to save Simulink simulation model as image or PDF
随机推荐
Periodic sharing of Alibaba Da Tao system model governance
ARM board adds routing function
30行代码实现微信朋友圈自动点赞
Flutter entry and advanced tour (6) Layout Widget
陈强教授《机器学习及R应用》课程 第十六章作业
ctfshow七夕杯2022
ftplib+ tqdm upload and download progress bar
Flutter入门进阶之旅(三)Text Widgets
正则引擎的几种分类
ViewPager fragments of nested data blank page abnormal problem analysis
CPU-MIPS32指令架构(无内锁流水线微处理器)
FPGA中串口通信的时钟频率和波特率计数
MySQL备份与恢复 (转载非原创)
Flutter入门进阶之旅(二)Hello Flutter
流量焦虑背后是企业对客户关系管理的不足
Bitmaps and bit operations
用plot_hist_numeric()实现画直方图
时间序列分析课程实验报告
AI basketball referee, walking is special, ask harden care don't care
陈强教授《机器学习及R应用》课程 第十三章作业