当前位置:网站首页>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;
}
};
边栏推荐
- How to solve the 0x80070005 error when the computer is reinstalled and the system is restored
- CPU-MIPS32 instruction architecture (unlocked pipeline microprocessor)
- WPF 实现带蒙版的 MessageBox 消息提示框
- 正则引擎的几种分类
- ctfshow七夕杯2022
- Yocto 可以下载的第三方库
- 【奖励公示】第23期 2022年7月奖励名单公示:社区明星评选 | 新人奖 | 博客同步 | 推荐奖
- 蓝桥杯线上模拟赛——Flex 经典骰子布局
- 快来扔鸡蛋。
- 如何求最大公约数?
猜你喜欢

Unicom network management protocol block diagram

七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)

jenkins api创建自定义pipeline

阿里大淘系模型治理阶段性分享

Map mixed density function and quantile added line

电脑重装系统还原0x80070005错误如何解决

IDEA Gradle 常遇问题(二)(持续更新)

gin's middleware and routing grouping

WSA toolkit installed app store tip doesn't work how to solve?

第六届”蓝帽杯“全国大学生网络安全技能大赛 半决赛
随机推荐
FFMPEG多媒体文件处理(ffmpeg文件的删除与重命名)
记录本项目中用到的系统调用与C库函数-2
ARM板卡增加路由功能
[FPGA Tutorial Case 48] Image Case 8 - Realization of Converting RGB Image to HSV Image Based on FPGA, Assisted Verification by MATLAB
Final assignment of R language data analysis in a university
面试题精选:神奇的斐波那契数列
GIN初探,环境安装
基于 R 语言的判别分析介绍与实践 LDA和QDA
面试攻略系列(四)-- 你不知道的大厂面试
陈强教授《机器学习及R应用》课程 第十四章作业
LeetCode 37.解数独
搭建大型分布式服务(二)搭建会员服务
5G China unicom AP:B SMS ASCII 转码要求
GIN Bind mode to get parameters and form validation
The sword refers to the offer, cuts the rope 2
IDEA Gradle 常遇问题(二)(持续更新)
5G Unicom Network Management Design Ideas
5G China unicom 直放站 网管协议 实时性要求
问题系列-如何修改或更新localhost里的值
Data Mining-06