解题思路利用 hashmap, key 为 vector 中的数, value 存放对应的下标。遍历 vector, 若当前值已经存在于 hashmap 中,判断当前的下标与 hashmap 中记录的下标差是否不大于 k,若是,返回 true; 否则,更新 hashmap 中该值的下标,继续下一个数。