반응형
1. 문제
https://leetcode.com/problems/find-the-duplicate-number/
2. 코드
/**
* @param {number[]} nums
* @return {number}
*/
var findDuplicate = function(nums) {
let map = new Map();
for(let n of nums){
if(map.get(n)) return n;
else map.set(n,1);
}
};
반응형
'리트코드 > midium' 카테고리의 다른 글
[리트코드] 17. Letter Combinations of a Phone Number - js (DFS) (0) | 2023.08.21 |
---|---|
[리트코드] 875. Koko Eating Bananas - js (이진탐색) (0) | 2023.08.20 |
[리트코드] 1870. Minimum Speed to Arrive on Time - js (이진탐색) (0) | 2023.08.19 |
[리트코드] 75. Sort Colors - js (0) | 2023.08.18 |
[리트코드] 3. Longest Substring Without Repeating Characters - js (슬라이딩 윈도우) (0) | 2023.08.16 |