当前位置:网站首页>The sword refers to Offer 56 - II. Number of occurrences of a number in an array II (bit operation)
The sword refers to Offer 56 - II. Number of occurrences of a number in an array II (bit operation)
2022-08-09 13:54:00 【to raise pigs】
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;
}
};
边栏推荐
- Rmarkdown Tutorial
- FFmpeg multimedia file processing (FFMPEG logging system)
- 剑指 Offer 43. 1~n 整数中 1 出现的次数(递归、数学)
- 一维数组&指针
- FFmpeg multimedia file processing (ffmpeg prints audio and video Meta information)
- Map mixed density function and quantile added line
- 剑指offer,剪绳子2
- error Trailing spaces not allowed no-trailing-spaces 9:14 error Unexpected trailing comma
- glibc 内存管理模型 释放 C库内存缓存
- 搭建大型分布式服务(二)搭建会员服务
猜你喜欢
![[极客大挑战 2019]Upload](/img/ed/062a89797c790189d9bd77b50335b0.png)
[极客大挑战 2019]Upload

Explanation of RTSP protocol

uni-app - uview Swiper 轮播图组件点击跳转链接(点击后拿到 item 行数据, 取出数据做操作)

novel research

GIN Bind mode to get parameters and form validation

5G China unicom AP:B SMS ASCII Transcoding Requirements

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

蓝桥杯线上模拟赛——Flex 经典骰子布局

5G China unicom 直放站 网管协议 实时性要求

How to reduce the size of desktop icons after the computer is reinstalled
随机推荐
How to reduce the size of desktop icons after the computer is reinstalled
GIN file upload and return
FFmpeg多媒体文件处理(ffmpeg打印音视频Meta信息)
Anta and Huawei Sports Health jointly verify the champion running shoes and lead Chinese sports with innovation
面试攻略系列(四)-- 你不知道的大厂面试
uni-app - uview Swiper 轮播图组件点击跳转链接(点击后拿到 item 行数据, 取出数据做操作)
glibc 内存管理模型 释放 C库内存缓存
jenkins api create custom pipeline
Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目
19、学习MySQL 索引
#WeArePlay | 与更多开发者一起,探索新世界
阿里大淘系模型治理阶段性分享
CPU-MIPS32指令架构(无内锁流水线微处理器)
IDEA Gradle 常遇问题(一)
WSA工具箱安装应用商店提示无法工作怎么解决?
NFS 特别注意权限的问题
RTSP协议的实现
How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
十六进制字符→十进制数字
陈强教授《机器学习及R应用》课程 第十六章作业