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

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

219. Contains Duplicate II

2019-11-14 09:20:05
字體:
供稿:網(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)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 离岛区| 建瓯市| 河北区| 顺义区| 于都县| 清苑县| 治多县| 北流市| 东至县| 淮滨县| 临潭县| 长治市| 蕉岭县| 子洲县| 岳阳市| 工布江达县| 澄城县| 松江区| 南汇区| 聂荣县| 古交市| 台北市| 廉江市| 聂荣县| 德兴市| 台湾省| 平定县| 龙岩市| 汾阳市| 隆化县| 曲水县| 黄龙县| 肃北| 四平市| 斗六市| 封开县| 偏关县| 固始县| 双峰县| 扎囊县| 革吉县|