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

首頁 > 學院 > 開發(fā)設計 > 正文

219. Contains Duplicate II

2019-11-11 07:33:27
字體:
來源:轉載
供稿:網友

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ā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 白朗县| 大丰市| 特克斯县| 荔浦县| 南皮县| 吴桥县| 鹤庆县| 平定县| 婺源县| 罗山县| 重庆市| 磐安县| 乡宁县| 彭阳县| 奉新县| 黎城县| 台山市| 嵩明县| 阳东县| 邢台市| 永丰县| 玉田县| 仪陇县| 阜城县| 杭锦后旗| 商洛市| 台南市| 大姚县| 油尖旺区| 托克逊县| 连云港市| 静宁县| 许昌市| 遂平县| 上蔡县| 盐山县| 屏东市| 韶关市| 大余县| 焉耆| 柘城县|