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
17 changes: 17 additions & 0 deletions doitchuu/CorrectParentheses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function solution(s) {
if (s[0] === ")") {
return false;
}

const stack = [];

for (let i = 0; i < s.length; i++) {
if (s[i] === "(") {
stack.push("(");
} else {
stack.pop();
}
}
Comment on lines +8 to +14
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.

")"가 먼저 채워지는 조건에서는 얼리 리턴으로 처리해주면 좋을 것 같아요!


return stack.length > 0 ? false : true;
}
6 changes: 6 additions & 0 deletions doitchuu/JadenCaseString.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.

메서드 활용이 깔끔하네요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function solution(s) {
return s.split(" ").map((char) => {
if (char.length === 0) return "";
return char[0].toUpperCase() + char.slice(1).toLowerCase();
}).join(" ");
}
4 changes: 4 additions & 0 deletions doitchuu/MaximumAndMinimum.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.

깔끔하네요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function solution(s) {
const numList = s.split(" ").sort((a, b) => a - b);
return numList[0] + " " + numList[numList.length - 1];
}
Loading