Leetcode 328 Contains Duplicate set和map应用
2016-01-16 20:23
381 查看
找出数组中重复的数,裸的map和set题
class Solution { public: bool containsDuplicate(vector<int>& nums) { map<int,int> mii; for (int i = 0;i<nums.size() ;++i) { if (mii.find(nums[i]) != mii.end()) { return true; } mii[nums[i]] = i; } return false; } };
相关文章推荐
- 3.3 启发式搜索
- Codeforces Gym 100015B Ball Painting 找规律
- 怎样将baidu地图中的baidu logo 去掉
- hdu1082 Matrix Chain Multiplication
- debian Jessie版安装中文输入法
- 3.6 产生式系统
- Codeforces educational round 5. E Sum of Remainders 数论 分块
- HDU 1789 Doing Homework again
- 服务器TIME_WAIT和CLOSE_WAIT详解和解决办法
- hdu2057 A + B Again
- [ILINK32 Error] Error: Unresolved external 'WSAIoctl'
- POJ 2027 No Brainer
- NSBundle 的理解和 mainBundle 类方法的详解
- set集合中的contains操作
- G面经prepare: X-Straight
- System.Net.Mail发送邮件
- Failed to execute goal on project ecz-wx: Could not resolve dependencies for project
- 【数组】Container With Most Water
- Codeforces Gym 100231F Solitaire 折半搜索
- Syntax error, annotations are only available if source level is 1.5