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

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

219. Contains Duplicate II

2019-11-11 06:50:02
字體:
來(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)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 淳化县| 宜良县| 穆棱市| 武义县| 台南县| 临西县| 陇西县| 香港 | 堆龙德庆县| 登封市| 福鼎市| 二连浩特市| 吉安市| 嫩江县| 鸡泽县| 富阳市| 怀集县| 深水埗区| 金平| 虹口区| 衡南县| 汾西县| 萨迦县| 固原市| 正宁县| 酒泉市| 济南市| 雷州市| 剑阁县| 塘沽区| 阳原县| 比如县| 阳高县| 社旗县| 河曲县| 彰化市| 泰来县| 泌阳县| 南涧| 遂川县| 揭西县|