Skip to content

Commit 6f730fe

Browse files
authored
[JustDevRae] 25.02.16 (#45)
* remove smallest number / 중급 * divisible numbers array / 중급 * duplicate number count / 기초 * matrix addition / 중급 * array element length / 기초 * rotate array / 기초 * slice array / 기초 * array algorithm md file * reverse string / 기초 * control Z / 기초 * dart game / 중급 * valid parentheses / 중급 * crane claw game / 중급 * pair count / 기초 * find point position / 기초 * login success / 기초 * card bundle / 중급 * make hamburger / 중급 * process / 심화 * morse code / 기초 * make B with A / 기초 * setting order care / 기초 * not finish runner / 중급 * rank order / 기초 * sameTree / 기초 * invert binary tree / 기초 * maximum depth of binary / 기초 * binary tree inorder traversal / 기초 * binary tree level order traversal / 중급 * 중복된 문자 제거 / 기초 * 한 번만 등장한 문자 / 기초 * 무작위로 K개의 수 뽑기 / 기초 * 소인수분해 / 중급 * Contains Duplicate / 기초
1 parent b9cb8c3 commit 6f730fe

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var containsDuplicate = function (nums) {
2+
const numSet = new Set(nums);
3+
return numSet.size !== nums.length;
4+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function solution(arr, k) {
2+
const uniqueSet = new Set();
3+
const result = [];
4+
5+
for (const num of arr) {
6+
if (!uniqueSet.has(num)) {
7+
uniqueSet.add(num);
8+
result.push(num);
9+
}
10+
if (result.length === k) break;
11+
}
12+
13+
while (result.length < k) {
14+
result.push(-1);
15+
}
16+
17+
return result;
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function solution(n) {
2+
let result = [];
3+
let divisor = 2;
4+
5+
while (n > 1) {
6+
if (n % divisor === 0) {
7+
result.push(divisor);
8+
n /= divisor;
9+
} else {
10+
divisor++;
11+
}
12+
}
13+
14+
return [...new Set(result)];
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function solution(my_string) {
2+
var answer = [...new Set(my_string)].join("");
3+
return answer;
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function solution(s) {
2+
const charSet = new Set();
3+
const duplicateSet = new Set();
4+
5+
for (const char of s) {
6+
if (charSet.has(char)) {
7+
duplicateSet.add(char);
8+
} else {
9+
charSet.add(char);
10+
}
11+
}
12+
13+
const uniqueChars = [...charSet].filter((char) => !duplicateSet.has(char));
14+
15+
return uniqueChars.sort().join("");
16+
}

0 commit comments

Comments
 (0)