From 79b467a73e12aaa37e548a4d656ca85f384bbef5 Mon Sep 17 00:00:00 2001 From: doitchuu Date: Thu, 12 Feb 2026 00:46:48 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20TwoSum=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doitchuu/TwoSum.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/doitchuu/TwoSum.js b/doitchuu/TwoSum.js index a260cdf..2190563 100644 --- a/doitchuu/TwoSum.js +++ b/doitchuu/TwoSum.js @@ -1,4 +1,17 @@ // MEMO: 편하신 언어로 작성 부탁드립니다. 해당 주석은 풀이 입력 시 지워주세요. -function twoSum(nums, target) { - -} +/** + * @param {number[]} nums + * @param {number} target + * @return {number[]} + */ +var twoSum = function(nums, target) { + for (let i = 0; i < nums.length; i++) { + for (let j = i + 1; j < nums.length; j++) { + if (nums[i] + nums[j] === target) { + const output = [i, j]; + + return output; + } + } + } +}; \ No newline at end of file From 8b2c4e1a8d12725af123c1580e0fedf04abd63ab Mon Sep 17 00:00:00 2001 From: doitchuu Date: Thu, 12 Feb 2026 00:53:53 +0900 Subject: [PATCH 2/6] =?UTF-8?q?typo:=20=EC=A3=BC=EC=84=9D=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doitchuu/TwoSum.js | 1 - 1 file changed, 1 deletion(-) diff --git a/doitchuu/TwoSum.js b/doitchuu/TwoSum.js index 2190563..abb9828 100644 --- a/doitchuu/TwoSum.js +++ b/doitchuu/TwoSum.js @@ -1,4 +1,3 @@ -// MEMO: 편하신 언어로 작성 부탁드립니다. 해당 주석은 풀이 입력 시 지워주세요. /** * @param {number[]} nums * @param {number} target From d4aeccad8e2fab7548b03191e191ffeef6ca581e Mon Sep 17 00:00:00 2001 From: doitchuu Date: Thu, 12 Feb 2026 00:54:24 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20Valid=20Parentheses=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=92=80=EC=9D=B4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doitchuu/ValidParentheses.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 doitchuu/ValidParentheses.js diff --git a/doitchuu/ValidParentheses.js b/doitchuu/ValidParentheses.js new file mode 100644 index 0000000..ac09268 --- /dev/null +++ b/doitchuu/ValidParentheses.js @@ -0,0 +1,35 @@ + +/** + * @param {string} s + * @return {boolean} + */ +function isValid(s) { + if (s.length % 2 !== 0) { + return false; + } + + let count = 0; + const stack = []; + + for (let i = 0; i < s.length; i++) { + if (s[i] === "(" || s[i] === "{" || s[i] === "[") { + stack.push(s[i]); + count++; + continue; + } + + if (stack[stack.length - 1] === "(" && s[i] === ")") { + stack.pop(); + } + + if (stack[stack.length - 1] === "{" && s[i] === "}") { + stack.pop(); + } + + if (stack[stack.length - 1] === "[" && s[i] === "]") { + stack.pop(); + } + } + + return stack.length > 0 && count !== (s.length / 2) ? false : true; +}; \ No newline at end of file From df40223adbc99760779b3906a6ed6dfe5c64271f Mon Sep 17 00:00:00 2001 From: doitchuu Date: Thu, 12 Feb 2026 00:55:14 +0900 Subject: [PATCH 4/6] =?UTF-8?q?add:=20MergeTwoSortedList=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=92=80=EC=9D=B4=20=EC=8B=A4=ED=8C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doitchuu/MergeTwoSortedLists.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 doitchuu/MergeTwoSortedLists.js diff --git a/doitchuu/MergeTwoSortedLists.js b/doitchuu/MergeTwoSortedLists.js new file mode 100644 index 0000000..254b534 --- /dev/null +++ b/doitchuu/MergeTwoSortedLists.js @@ -0,0 +1,15 @@ +/** + * Definition for singly-linked list. + * function ListNode(val, next) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + */ +/** + * @param {ListNode} list1 + * @param {ListNode} list2 + * @return {ListNode} + */ +var mergeTwoLists = function(list1, list2) { + // MEMO: 이 문제는 풀지 못했습니다. +}; \ No newline at end of file From 19d5c319741c467af31f768d23439098e9872f0a Mon Sep 17 00:00:00 2001 From: doitchuu Date: Thu, 12 Feb 2026 00:56:03 +0900 Subject: [PATCH 5/6] =?UTF-8?q?add:=20Best=20Time=20to=20Buy=20and=20Sell?= =?UTF-8?q?=20Stock=20=EB=AC=B8=EC=A0=9C=20=ED=92=80=EC=9D=B4=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=20(=EC=8B=9C=EA=B0=84=20=EC=B4=88=EA=B3=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doitchuu/BestTimeToBuyAndSellStock.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 doitchuu/BestTimeToBuyAndSellStock.js diff --git a/doitchuu/BestTimeToBuyAndSellStock.js b/doitchuu/BestTimeToBuyAndSellStock.js new file mode 100644 index 0000000..172da81 --- /dev/null +++ b/doitchuu/BestTimeToBuyAndSellStock.js @@ -0,0 +1,20 @@ +/** + * @param {number[]} prices + * @return {number} + */ +var maxProfit = function(prices) { + // MEMO: 시간 초과! + let maxPrice = 0; + + for (let i = 0; i < prices.length - 1; i++) { + for (let j = i + 1; j < prices.length; j++) { + const price = prices[i] - prices[j]; + + if (price < 0) { + maxPrice = Math.max(maxPrice, Math.abs(price)); + } + } + } + + return maxPrice; +}; \ No newline at end of file From 04982cb477033e8195813ef798f85b5bbe679e99 Mon Sep 17 00:00:00 2001 From: doitchuu Date: Thu, 12 Feb 2026 00:57:25 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20EOD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doitchuu/BestTimeToBuyAndSellStock.js | 2 +- doitchuu/MergeTwoSortedLists.js | 2 +- doitchuu/TwoSum.js | 2 +- doitchuu/ValidParentheses.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doitchuu/BestTimeToBuyAndSellStock.js b/doitchuu/BestTimeToBuyAndSellStock.js index 172da81..7d78bda 100644 --- a/doitchuu/BestTimeToBuyAndSellStock.js +++ b/doitchuu/BestTimeToBuyAndSellStock.js @@ -17,4 +17,4 @@ var maxProfit = function(prices) { } return maxPrice; -}; \ No newline at end of file +}; diff --git a/doitchuu/MergeTwoSortedLists.js b/doitchuu/MergeTwoSortedLists.js index 254b534..fe0f383 100644 --- a/doitchuu/MergeTwoSortedLists.js +++ b/doitchuu/MergeTwoSortedLists.js @@ -12,4 +12,4 @@ */ var mergeTwoLists = function(list1, list2) { // MEMO: 이 문제는 풀지 못했습니다. -}; \ No newline at end of file +}; diff --git a/doitchuu/TwoSum.js b/doitchuu/TwoSum.js index abb9828..db22ab9 100644 --- a/doitchuu/TwoSum.js +++ b/doitchuu/TwoSum.js @@ -13,4 +13,4 @@ var twoSum = function(nums, target) { } } } -}; \ No newline at end of file +}; diff --git a/doitchuu/ValidParentheses.js b/doitchuu/ValidParentheses.js index ac09268..a84fc14 100644 --- a/doitchuu/ValidParentheses.js +++ b/doitchuu/ValidParentheses.js @@ -32,4 +32,4 @@ function isValid(s) { } return stack.length > 0 && count !== (s.length / 2) ? false : true; -}; \ No newline at end of file +};