当前位置:网站首页>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;
}
};
边栏推荐
- GIN中GET POST PUT DELETE请求
- 自己做了个nodejs+epxress+mysql的小项目,怎么才能让别人通过互联网访问呢?
- Data Mining-06
- 【FPGA教程案例48】图像案例8——基于FPGA的RGB图像转化为HSV图像的实现,通过MATLAB进行辅助验证
- 十进制数字→十六进制字符
- render解析
- telnet+ftp 对设备进行 操控 和 升级
- ARM板卡增加路由功能
- 陈强教授《机器学习及R应用》课程 第十五章作业
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 14 Assignment
猜你喜欢
kustomize entry example and basic syntax instructions
电脑重装系统后桌面图标如何调小尺寸
render解析
FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)
面试攻略系列(三)-- 高级开发工程师面试问些啥?
[极客大挑战 2019]Upload
5G 联通网管设计思路
GIN a preliminary study, the environment is installed
5G China unicom 一般性异常处理
#WeArePlay | 与更多开发者一起,探索新世界
随机推荐
Rmarkdown Tutorial
Come and throw eggs.
Process/Thread related in Sandbox - 1
驻波比计算方法
昇腾AI开发者创享日南京站!一起CANN机器狗+AI机械臂实现硬核智慧救援!燃爆现场~
CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)
十进制数字→十六进制字符
RTSP协议讲解
Ledong Fire Rescue Brigade was invited to carry out fire safety training for cadres
leetcode 20. Valid Parentheses 有效的括号(中等)
Clock frequency and baud rate count for serial communication in FPGA
正则引擎的几种分类
记录本项目中用到的系统调用与C库函数-2
GIN中GET POST PUT DELETE请求
Professor Chen Qiang the machine learning and R application course chapter 18 assignments
Professor Chen Qiang's "Machine Learning and R Application" course Chapter 16 Assignment
Final assignment of R language data analysis in a university
Deep Learning Based on R Language - Simple Regression Case
FFmpeg multimedia file processing (implementation of ffmpeg operation directory and list)