diff --git a/doitchuu/CorrectParentheses.js b/doitchuu/CorrectParentheses.js new file mode 100644 index 0000000..a0cc10d --- /dev/null +++ b/doitchuu/CorrectParentheses.js @@ -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(); + } + } + + return stack.length > 0 ? false : true; +} diff --git a/doitchuu/JadenCaseString.js b/doitchuu/JadenCaseString.js new file mode 100644 index 0000000..762292c --- /dev/null +++ b/doitchuu/JadenCaseString.js @@ -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(" "); +} diff --git a/doitchuu/MaximumAndMinimum.js b/doitchuu/MaximumAndMinimum.js new file mode 100644 index 0000000..8ee5f68 --- /dev/null +++ b/doitchuu/MaximumAndMinimum.js @@ -0,0 +1,4 @@ +function solution(s) { + const numList = s.split(" ").sort((a, b) => a - b); + return numList[0] + " " + numList[numList.length - 1]; +}