原题地址

遍历所有数字,统计每一位出现的次数,模3即为只出现一次的数字在那一位的情况。

代码:

 int singleNumber(int A[], int n) {
int count[] = {}; for (int i = ; i < n; i++) {
for (int j = ; j < ; j++) {
count[j] += A[i] & ;
A[i] >>= ;
}
} int res = ;
for (int j = ; j < ; j++) {
res += (count[j] % ) << j;
} return res;
}

Leetcode#137 Single Number II的更多相关文章

  1. LeetCode 137. Single Number II(只出现一次的数字 II)

    LeetCode 137. Single Number II(只出现一次的数字 II)

  2. Leetcode 137 Single Number II 仅出现一次的数字

    原题地址https://leetcode.com/problems/single-number-ii/ 题目描述Given an array of integers, every element ap ...

  3. LeetCode 137 Single Number II(仅仅出现一次的数字 II)(*)

    翻译 给定一个整型数组,除了某个元素外其余的均出现了三次. 找出这个元素. 备注: 你的算法应该是线性时间复杂度. 你能够不用额外的空间来实现它吗? 原文 Given an array of inte ...

  4. [LeetCode] 137. Single Number II 单独数 II

    Given a non-empty array of integers, every element appears three times except for one, which appears ...

  5. [LeetCode] 137. Single Number II 单独的数字之二

    Given a non-empty array of integers, every element appears three times except for one, which appears ...

  6. 详解LeetCode 137. Single Number II

    Given an array of integers, every element appears three times except for one, which appears exactly ...

  7. leetcode 137. Single Number II ----- java

    Given an array of integers, every element appears three times except for one. Find that single one. ...

  8. Java [Leetcode 137]Single Number II

    题目描述: Given an array of integers, every element appears three times except for one. Find that single ...

  9. LeetCode 137 Single Number II 数组中除了一个数外,其他的数都出现了三次,找出这个只出现一次的数

    Given an array of integers, every element appears three times except for one, which appears exactly ...

  10. Java for LeetCode 137 Single Number II

    Given an array of integers, every element appears three times except for one. Find that single one. ...

随机推荐

  1. phpMyAdmin提示“Access denied for user 'root'@'localhost' (using password: NO)”的解决办法

    一.错误内容 在用thinkPHP登陆phpMyAdmin时遇到以下错误 #1045 - Access denied for user 'root'@'localhost' (using passwo ...

  2. php小算法总结一(数组重排,进制转换)

    1.两个有序数组组合成一个新的有序数组 <?php $arr1=array(2,5,7,9,12); $arr2=array(3,4,6,8,10,11); function merge_sor ...

  3. php 购物车的例子

    网上搜到的,简单容易理解.cookie存购物车ID,db存购物车数据. //购物车session的产生代码   1 if(! $session && ! $scid) {    2 / ...

  4. php手册学习

    整型:int   转换为整型:intval(str)  32位最大值64位最大值 不存在整除语法:应用round();四舍五入.integer去除小数. $a = 1234; //十进制数 $a = ...

  5. devexpress 控制面板汉化方式 参考信息

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. C# 多线程操作样例

    using System; using System.Threading; //引用多线程 namespace ThreadTest { public class Alpha { public voi ...

  7. 从客户端检测到有潜在危险的Request.Form 值【转】

    asp.net开发中,经常遇到“从客户端检测到有潜在危险的Request.Form 值”错误提示,很多人给出的解决方案是: 1.web.config文档<system.web>后面加入这一 ...

  8. python 校招信息爬虫程序

    发现一个爬虫程序,正在学习中: https://github.com/lizherui/spider_python

  9. r

    http://vgoulet.act.ulaval.ca/en/emacs/mac/ mean() 均值 sd()标准差 http://www.walware.de/it/downloads/stat ...

  10. WebApp JS 打开 app

    产品需求:分享出去的链接比如到微信朋友圈,微博的H5页面,添加一个按钮 open App 用来打开并启动自己公司的APP (如果当前手机已经安装自己公司的APP) 废话少说直接上代码: <inp ...