219.Contains Duplicate II
219.Contains Duplicate II
难度:Easy
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 absolute difference between i and j is at most k.
新建一个map保存相同元素的索引值,然后比较相同元素索引值中相邻两个索引是否有满足条件的。
执行用时 :56 ms, 在所有 C++ 提交中击败了50.75%的用户 内存消耗 :22 MB, 在所有 C++ 提交中击败了5.03%的用户
Last updated