Contains Duplicate II
2015-06-10 21:16
477 查看
import java.util.Hashtable; public class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { Hashtable<Integer, Integer> intToIntHashtable = new Hashtable<Integer, Integer>(); for(int i = 0; i < nums.length; ++i) { if(intToIntHashtable.containsKey(nums[i]) && i - intToIntHashtable.get(nums[i]) <= k) { return true; }else { intToIntHashtable.put(nums[i], i); } } return false; } }
相关文章推荐
- 回收子进程函数waitpid详解
- HDU 1532Drainage Ditches(最大流模板题 ISAP)
- 219Contains Duplicate II
- VS 2012 No exports were found that match the constraint 解决办法
- WSAIoctl 函数详解
- Training:动态规划
- RAID磁盘阵列
- RevitAPI: 创建四通失败CrossFitting - InvalidOperationException: failed to insert cross.
- [leetcode 11]Container With Most Water
- 贪心 Codeforces Round #173 (Div. 2) B. Painting Eggs
- Failure [INSTALL_FAILED_OLDER_SDK]
- 技术团队如何招聘和管理,如何避免低效率的官僚作风,来看看Airbnb的经验
- Opencv研读笔记:haartraining程序之icvCreateCARTStageClassifier函数详解~
- Factorial Trailing Zeroes-Leetcode
- 人工智能和机器学习领域有哪些有趣的开源项目?
- AWS中国北京区域推出AWS CloudTrail服务
- 解决使用repo下载opencontrail出现的问题
- 申请baidu地图 sdk,获取sha1步骤
- THE DRUNK JAILER
- THE DRUNK JAILER 分类: POJ 2015-06-10 14:50 13人阅读 评论(0) 收藏