题目链接

  题目要求:

  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?

  这道题属于比较简单的,程序如下:

 class Solution {
public:
int singleNumber(vector<int>& nums) {
unordered_map<int, int> hashMap;
int sz = nums.size();
for(int i = ; i < sz; i++)
hashMap[nums[i]]++; unordered_map<int, int>::iterator itr = hashMap.begin();
for(; itr != hashMap.end(); itr++)
{
if(itr->second == )
return itr->first;
} return INT_MIN;
}
};

LeetCode之“散列表”:Single Number的更多相关文章

  1. LeetCode(137) Single Number II

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

  2. LeetCode之“散列表”:Two Sum && 3Sum && 3Sum Closest && 4Sum

    1. Two Sum 题目链接 题目要求: Given an array of integers, find two numbers such that they add up to a specif ...

  3. 【LeetCode OJ 136】Single Number

    题目链接:https://leetcode.com/problems/single-number/ 题目:Given an array of integers, every element appea ...

  4. leetcode文章137称号-Single Number II

    #include<stdio.h> #include<stdlib.h> int singleNumber(int* nums, int numsSize) { int cou ...

  5. [LeetCode&Python] Problem 136. Single Number

    Given a non-empty array of integers, every element appears twice except for one. Find that single on ...

  6. LeetCode(136) Single Number

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

  7. LeetCode之“散列表”:Isomorphic Strings

    题目链接 题目要求: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic i ...

  8. LeetCode之“散列表”:Contains Duplicate && Contains Duplicate II

     1. Contains Duplicate 题目链接 题目要求: Given an array of integers, find if the array contains any duplica ...

  9. LeetCode之“散列表”:Valid Sudoku

    题目链接 题目要求: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku boar ...

随机推荐

  1. django-redis

    linuxapt-get install redis-serverpip install django-redis vim /etc/redis/redis.conf maxmemory 20mb s ...

  2. Kafka学习笔记2: 快速入门

    在开始Kafka环境搭建之前,首先要安装Linux系统,并在Linux系统上安装JDK1.8版本,关于linux虚拟机的安装和linux系统下jdk的安装可以参考我的博文: http://blog.c ...

  3. RxJava(三) flatMap操作符用法详解

    欢迎转载,转载请标明出处: http://blog.csdn.net/johnny901114/article/details/51532776 本文出自:[余志强的博客] flatMap操作符的作用 ...

  4. BeanUtils制作自定义的转换器

    一般来说,BeanUtils自带的Converter基本上可以满足我们在开发过程中的使用了,然而很多时候我们还是需要自定义一些转换器. MyBean.java package beanutils; i ...

  5. [ExtJS5学习笔记]第九节 Extjs5的mvc与mvvm框架结构简介

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/38537431 本文作者:sushengmiyan ------------------ ...

  6. 【编程练习】poj1111

    Image Perimeters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8632   Accepted: 5168 ...

  7. Description Resource Path Location Type AndroidManifest.xml file missing!

    这个问题又找了好久.国内回答的确不敢恭维. 本回答来自谷歌:   This is build issue. Go to Menu in eclipse, Project>clean then P ...

  8. ios7内购、Game Center 实现 in-App Purchases & Game Center

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=514 昨天使用ios7SDK b ...

  9. Java基础---集合框架---迭代器、ListIterator、Vector中枚举、LinkedList、ArrayList、HashSet、TreeSet、二叉树、Comparator

    为什么出现集合类? 面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,就对对象进行存储,集合就是存储对象最常用的一种方式. 数组和集合类同是容器,有何不同? 数组虽然也可以存储对 ...

  10. SpringMVC源码分析--容器初始化(五)DispatcherServlet

    上一篇博客SpringMVC源码分析--容器初始化(四)FrameworkServlet我们已经了解到了SpringMVC容器的初始化,SpringMVC对容器初始化后会进行一系列的其他属性的初始化操 ...