From cd1c1e2682ad3cece0c87fc627e9ccb9bb2a00f1 Mon Sep 17 00:00:00 2001 From: sik9252 Date: Fri, 13 Feb 2026 08:44:22 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20TwoSum=20=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sik9252/TwoSum.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sik9252/TwoSum.js b/sik9252/TwoSum.js index a260cdf..d042c68 100644 --- a/sik9252/TwoSum.js +++ b/sik9252/TwoSum.js @@ -1,4 +1,9 @@ -// MEMO: 편하신 언어로 작성 부탁드립니다. 해당 주석은 풀이 입력 시 지워주세요. -function twoSum(nums, target) { - -} +var twoSum = function (nums, target) { + for (let i = 0; i < nums.length - 1; i++) { + for (let j = i + 1; j < nums.length; j++) { + if (nums[i] + nums[j] === target) { + return [i, j]; + } + } + } +}; From 93a6cdad33b06c9389b53f875c9787e0e541a58d Mon Sep 17 00:00:00 2001 From: sik9252 Date: Fri, 13 Feb 2026 08:44:49 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20ValidParentheses=20=ED=92=80?= =?UTF-8?q?=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 --- sik9252/ValidParentheses.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 sik9252/ValidParentheses.js diff --git a/sik9252/ValidParentheses.js b/sik9252/ValidParentheses.js new file mode 100644 index 0000000..f6b02ad --- /dev/null +++ b/sik9252/ValidParentheses.js @@ -0,0 +1,23 @@ +var isValid = function (s) { + if (s.length % 2 !== 0) return false; + + const stack = []; + const map = { + ")": "(", + "]": "[", + "}": "{", + }; + + for (const char of s) { + if (map[char]) { + const topElement = stack.pop(); + if (topElement !== map[char]) { + return false; + } + } else { + stack.push(char); + } + } + + return stack.length === 0; +}; From 3dbda65f734f4644375016efe73a5734e393a3ef Mon Sep 17 00:00:00 2001 From: sik9252 Date: Fri, 13 Feb 2026 08:45:12 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20MergeTwoSortedList=20=ED=92=80?= =?UTF-8?q?=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 --- sik9252/MergeTwoSortedList.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sik9252/MergeTwoSortedList.js diff --git a/sik9252/MergeTwoSortedList.js b/sik9252/MergeTwoSortedList.js new file mode 100644 index 0000000..66c4801 --- /dev/null +++ b/sik9252/MergeTwoSortedList.js @@ -0,0 +1,24 @@ +var mergeTwoLists = function (list1, list2) { + const start = new ListNode(-1); + let curr = start; + + while (list1 !== null && list2 !== null) { + if (list1.val <= list2.val) { + curr.next = list1; + list1 = list1.next; + } else { + curr.next = list2; + list2 = list2.next; + } + + curr = curr.next; + } + + if (list1 !== null) { + curr.next = list1; + } else { + curr.next = list2; + } + + return start.next; +}; From 0e26254eb76145ac9749886afc0bbb51fe0b4b6c Mon Sep 17 00:00:00 2001 From: sik9252 Date: Fri, 13 Feb 2026 08:45:29 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20BestTimeToBuyAndSellStock=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 --- sik9252/BestTimeToBuyAndSellStock.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sik9252/BestTimeToBuyAndSellStock.js diff --git a/sik9252/BestTimeToBuyAndSellStock.js b/sik9252/BestTimeToBuyAndSellStock.js new file mode 100644 index 0000000..bc2ef33 --- /dev/null +++ b/sik9252/BestTimeToBuyAndSellStock.js @@ -0,0 +1,14 @@ +var maxProfit = function (prices) { + let minPrice = Infinity; + let currentProfit = 0; + + for (let i = 0; i < prices.length; i++) { + if (prices[i] < minPrice) { + minPrice = prices[i]; + } else if (prices[i] - minPrice > currentProfit) { + currentProfit = prices[i] - minPrice; + } + } + + return currentProfit; +};