Skip to content

Commit a815638

Browse files
committed
contains duplicate solution 1
1 parent 0e5ffe5 commit a815638

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

contains-duplicate/hyejj19.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function containsDuplicate(nums: number[]): boolean {
2+
const numsMap = new Map();
3+
nums.forEach(n => {
4+
numsMap.set(n, (numsMap.get(n) || 0) + 1);
5+
});
6+
7+
for (const [_, count] of numsMap) {
8+
if (count >= 2) return true;
9+
}
10+
11+
return false;
12+
}

0 commit comments

Comments
 (0)