Description:

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

找出只出现一次的数。

public class Solution {
public int singleNumber(int[] nums) {
Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i=0; i<nums.length; i++) {
if(map.containsKey(nums[i])) {
int times = map.get(nums[i]);
map.put(nums[i], times+1);
}
else
map.put(nums[i], 1);
}
Set<Integer> set = map.keySet();
for(int i : set) {
if(map.get(i) == 1) {
return i;
}
}
return 0; }
}

最新文章

  1. 分布式架构中一致性解决方案——Zookeeper集群搭建
  2. .net Global.asax文件使用
  3. 水灾(sliker.cpp/c/pas) 1000MS 64MB
  4. 软件测试——boost单元测试 C++
  5. linux 给用户添加进新的组
  6. 《linux内核完全剖析》笔记03-进程创建
  7. C# 遍历泛型集合
  8. 百度编辑器的内容改变事件监听bug
  9. xshell 与 putty
  10. 移动端tab滑动和上下拉刷新加载
  11. 浅谈JAVA8引入的接口默认方法
  12. Linux.安装phantomjs
  13. 使用sqlyog或者navicat连接mysql提示1862错误解决
  14. git Disconnected:No supported authentication methods available问题解决
  15. Linux 清楚历史history命令的一个简单方法
  16. 在DevExpress程序中使用内置的图标构建美观的界面元素【转】
  17. MYSQL一次千万级连表查询优化
  18. 实现vue2.0响应式的基本思路
  19. Flutter: 图解 ListView 的多种绑定方式
  20. [BZOJ1974][SDOI2010]代码拍卖会[插板法]

热门文章

  1. iio adc转换应用编写
  2. 【mybase】绿色版---mybase非常好用的笔记软件
  3. jquery树形表格实现方法
  4. chkconfig关闭必须的5个服务或者取出第一列
  5. c# dataTable 合并两个列到一个新列中
  6. Hibernate- 基本查询
  7. java-基于Servlet3.0的文件上传
  8. Applet Mode
  9. zend opcache的最佳设置
  10. WCF(一)