Contains Duplicate II
2015-07-07 20:12
381 查看
[code]class Solution { public: bool containsNearbyDuplicate(vector<int>& nums, int k) { map<int, int> hashRecord; int length = nums.size(); for(int i = 0; i < length; i++) { if(hashRecord.count(nums[i]) && i - hashRecord[nums[i]] <= k) return true; else hashRecord[nums[i]] = i; } return false; } };
相关文章推荐
- 【LeetCode】219. Contains Duplicate II
- Contains Duplicate II
- 实战weblogic集群之创建domain,AdminServer
- Contains Duplicate
- INSTALL_PARSE_FAILED_NO_CERTIFICATES 解决办法
- 【LeetCode】217. Contains Duplicate (2 solutions)
- 使用Genymotion调试出现错误INSTALL_FAILED_CPU_ABI_INCOMPATIBLE解决办法
- 进程控制 [fork() exec() wait() waitpid()]
- AIX Study之--AIX网卡配置管理(ent0、en0、et0)
- Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or d.......
- Main.storyboard
- AIX Study之--AIX网卡配置管理(ent0、en0、et0)
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- LeetCode Container With Most Water
- WSAIoctl
- AIX Study之--用户访问系统资源限制配置
- AIX Study之--AIX用户资源访问限制配置
- Grails边做边学入门篇[0]--------讲讲什么是Grails
- Git Pull Failed: CONFLICT (content): Merge conflict in camus-aggregator/camus-admin-web/src/main/web
- Tuning TIME_WAIT