Skip to content

Commit a376b55

Browse files
committed
feat: containsDuplicate 풀이
1 parent 0e5ffe5 commit a376b55

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

contains-duplicate/grapefruit13.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @description nums 배열에서 중복 숫자 확인
3+
* @param nums - 숫자 배열
4+
* @returns boolean - 중복 숫자 여부
5+
*/
6+
const containsDuplicate = (nums: number[]) => {
7+
const hasSeen = new Set<number>();
8+
9+
for (const num of nums) {
10+
if (hasSeen.has(num)) {
11+
return true;
12+
}
13+
hasSeen.add(num);
14+
}
15+
return false;
16+
};

0 commit comments

Comments
 (0)