Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sik9252/ ContainsDuplicate.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

슬기님 풀이와 같군요!
Set에 모든 배열을 넣지않고 하나씩 확인하면서 얼리 리턴을 하면 조금 더 빠를 수 있을 것 같아요

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var containsDuplicate = function (nums) {
const removeDuplicate = new Set(nums);
return nums.length === removeDuplicate.size ? false : true;
};
26 changes: 26 additions & 0 deletions sik9252/ RomanToInteger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var romanToInt = function (s) {
const map = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000,
};

let result = 0;

for (let i = 0; i < s.length; i++) {
const current = map[s[i]];
const next = map[s[i + 1]];
Comment on lines +15 to +16
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수로 빼니 코드 이해가 쉬운 것 같아요 👍


if (current < next) {
result -= current;
} else {
result += current;
}
}

return result;
};
Loading