查找数组中只出现一次的数(一)——Leetcode系列(十四)
来源:互联网 发布:手机淘宝延迟收货 编辑:程序博客网 时间:2024/06/01 07:41
Single Number
Given an array of integers, every element appears twice except for one.
Find that single one.
Note:
Your algorithm should have a linear runtime complexity.
Could you implement it without using extra memory?
My Answer:
public class Solution { public int singleNumber(int[] A) { Set<Integer> set = new HashSet<Integer>(); int length = A.length; for(int i = 0; i < length; i++){ if(set.contains(A[i])){ set.remove(new Integer(A[i])); }else{ set.add(A[i]); } } Iterator<Integer> ite = set.iterator(); return ite.next(); }}
题目来源:https://oj.leetcode.com/problems/single-number/
0 0
- 查找数组中只出现一次的数(一)——Leetcode系列(十四)
- 查找数组中只出现一次的数
- 查找数组中只出现一次的数
- 查找数组中只出现一次的一个数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的数
- 数组中只出现一次的(一个数、两个数、三个数)
- Single Number 数组找只出现一次的数@LeetCode
- Dijkstra POJ1062 昂贵的聘礼
- 对象所产生的构造函数,复制构造函数,析构,赋值函数
- form表单传递数组数据、php脚本接收
- 我写过的软件之FileExpert
- php和javascript中Json操作总结
- 查找数组中只出现一次的数(一)——Leetcode系列(十四)
- TJU4070ROAD dfs条件回溯
- 菜鸟,大牛和教主,三者的区别
- 机器学习中的相似性度量
- LUA 编辑器 易语言版 源码
- 新版的ViewHolder
- mybatis实现继承映射
- Android UI 优化——使用HierarchyViewer工具
- Web基础架构:负载均衡和LVS