国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

219. Contains Duplicate II

2019-11-11 07:28:21
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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.

class Solution {public: bool containsNearbyDuplicate(vector<int>& nums, int k) { int size = nums.size(); map<int, int> m; for(int i = 0; i < size; ++i){ if(m.count(nums[i])){ if(i - m[nums[i]] <= k) return true; } m[nums[i]] = i; } return false; }};
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 潼关县| 丰台区| 平乡县| 文成县| 乌兰县| 綦江县| 文安县| 和平区| 连南| 竹山县| 昌平区| 东光县| 福安市| 广昌县| 九龙坡区| 西贡区| 江津市| 博野县| 鄂温| 连城县| 若尔盖县| 汉寿县| 宣化县| 东海县| 资阳市| 安泽县| 阿图什市| 宾川县| 永康市| 喜德县| 凭祥市| 丽江市| 施秉县| 百色市| 余干县| 哈巴河县| 大名县| 开原市| 高密市| 保靖县| 河池市|