Skip to content
Open
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
10 changes: 10 additions & 0 deletions doitchuu/ContainsDuplicate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @param {number[]} nums
* @return {boolean}
*/
var containsDuplicate = function(nums) {
const arrLength = nums.length;
const set = new Set(nums);

return arrLength !== set.size;
Copy link
Collaborator

Choose a reason for hiding this comment

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

오 길이 비교는 생각을 못했네요

};
29 changes: 29 additions & 0 deletions doitchuu/RomanToInteger.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

저랑 풀이가 똑같네요!ㅎ

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @param {string} s
* @return {number}
*/
var romanToInt = function(s) {
const romanMap = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
"C": 100,
"D": 500,
"M": 1000
};
let sum = 0;

for (let i = 0; i < s.length - 1; i++) {
const current = romanMap[s[i]];
const next = romanMap[s[i + 1]];

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

return sum += romanMap[s[s.length - 1]];
};
Loading