
Problem
Analysis
Solution
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class : def containsNearbyDuplicate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ lookup = dict() for i, num in enumerate(nums): if num in lookup and i - lookup[num] <= k: return True lookup[num] = i return False
|
Link
219. Contains Duplicate II
近期评论