219. Contains Duplicates II
Given an array of integers and an integer
k
, find out whether there are two distinct indicesi
andj
in the array such that nums[i] = nums[j] and the absolute difference betweeni
andj
is at mostk
.
给一个数组, 看nums[i]
附近的k
个数里, 是否有相同的. 也就是说, 如果存在nums[i] == nums[j]
和abs(j-i) <= k
则返回True
否则返回 False
.