leetcode --Contains Duplicate II
来源:互联网 发布:ad线路板画图软件 编辑:程序博客网 时间:2024/06/06 07:25
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and jis at most k.
注:特殊情况k=0时直接返回false
bool containsNearbyDuplicate(int* nums, int numsSize, int k) {
if (k == 0)
return false;
for(int i = 0; i < numsSize - 1; i++) {
for(int j = i + 1; j <= i + k && j < numsSize; j++) {
if (nums[i] == nums[j])
return true;
}
}
return false;
}
0 0
- [LeetCode]Contains Duplicate II
- [LeetCode] Contains Duplicate II
- leetcode Contains Duplicate II
- LeetCode Contains Duplicate II
- [leetcode] Contains Duplicate II
- LeetCode Contains Duplicate II
- 【leetcode】Contains Duplicate II
- leetcode--Contains Duplicate II
- [leetcode]Contains Duplicate II
- [leetCode] Contains Duplicate II
- LeetCode: Contains Duplicate II
- LeetCode Contains Duplicate II
- LeetCode | Contains Duplicate II
- LeetCode Contains Duplicate II
- 【LeetCode】Contains Duplicate II
- leetcode: Contains Duplicate II
- LeetCode Contains Duplicate II
- Leetcode: Contains Duplicate II
- Linux下部署ASP.NET项目
- http://blog.csdn.net/jeepxiaozi/article/details/43373243
- Xcode 6中添加预编译pch文件
- Linux学习14_linux下提示bash:command not found
- 单色三角形问题结论
- leetcode --Contains Duplicate II
- Git 的介绍
- Apache+PHP+MySQL Configuration
- MySQL字符串大小写转换函数
- 应用程序崩溃定位查找 (二)
- 黑马程序员——Java基础-------面向对象(三)
- web.xml配置文件
- 从后端到页面:如何全方位监控 Ruby 应用?
- js格式化人民币金额¥999.99