From 718d0c3eb55ab971cde23c62fc3c671c8f6a6969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Mon, 15 Dec 2025 23:03:57 +0900 Subject: [PATCH 1/3] feat: valid-parentheses --- valid-parentheses/hozzijeong.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 valid-parentheses/hozzijeong.js diff --git a/valid-parentheses/hozzijeong.js b/valid-parentheses/hozzijeong.js new file mode 100644 index 0000000000..caae0603ab --- /dev/null +++ b/valid-parentheses/hozzijeong.js @@ -0,0 +1,30 @@ +/** + * @param {string} s + * @return {boolean} + */ +var isValid = function(s) { + const smallBracket = ['(',')']; + const middleBracket = ['{','}']; + const largeBracket = ['[',']']; + + + const leftStack = []; + + for(const char of s) { + if(char === smallBracket[0]){ + leftStack.push(smallBracket[1]) + }else if (char === middleBracket[0]){ + leftStack.push(middleBracket[1]) + }else if(char === largeBracket[0]){ + leftStack.push(largeBracket[1]) + }else{ + const last = leftStack.pop(); + if(char === smallBracket[1] && last !== char) return false; + if(char === middleBracket[1] && last !== char) return false; + if(char === largeBracket[1] && last !== char) return false; + } + } + + + return leftStack.length === 0 +}; From 88fe78603c87ae66020b0ba3b09d3840f9f74d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Tue, 16 Dec 2025 23:01:32 +0900 Subject: [PATCH 2/3] feat: container-with-most-water --- container-with-most-water/hozzijeong.js | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 container-with-most-water/hozzijeong.js diff --git a/container-with-most-water/hozzijeong.js b/container-with-most-water/hozzijeong.js new file mode 100644 index 0000000000..dd808b7b9d --- /dev/null +++ b/container-with-most-water/hozzijeong.js @@ -0,0 +1,36 @@ +/** + * @param {number[]} height + * @return {number} + */ +var maxArea = function(height) { + // x축이 가장 길면서 y축 역시 가장 높은 즉 높이가 가장 높은 값을 찾으라는 의미. + // startIndex값과 그 값에 해당하는 height를 받고 + // endIndex의 값과 그 값에 해당하는 height를 받는다. + // 여기서 가장 큰 점은 startIndex와 endIndex가 멀면 멀수록 좋다 + // 그리고 그 값을 하나씩 줄여가면서 더 큰 값을 찾아 적용한다 + + let max = 0; + + let startIndex = 0; + let endIndex = height.length -1; + + while(startIndex < endIndex){ + const startHeight = height[startIndex]; + const endHeight = height[endIndex]; + + const xLength = endIndex - startIndex; + const minHeight = Math.min(startHeight, endHeight); + + const size = xLength * minHeight; + + max = Math.max(size,max); + + if(startHeight >= endHeight){ + endIndex -=1; + }else{ + startIndex +=1; + } + }; + + return max +}; From 78e360453872fabb098af38905f3b41830bad9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=B8=EC=A7=84?= <50974359+hozzijeong@users.noreply.github.com> Date: Wed, 17 Dec 2025 19:19:58 +0900 Subject: [PATCH 3/3] feat: design-add-and-search-words --- .../hozzijeong.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 design-add-and-search-words-data-structure/hozzijeong.js diff --git a/design-add-and-search-words-data-structure/hozzijeong.js b/design-add-and-search-words-data-structure/hozzijeong.js new file mode 100644 index 0000000000..78223731df --- /dev/null +++ b/design-add-and-search-words-data-structure/hozzijeong.js @@ -0,0 +1,39 @@ + +var WordDictionary = function() { + const dictionary = new Set(''); + + this.dictionary = dictionary +}; + +/** + * @param {string} word + * @return {void} + */ +WordDictionary.prototype.addWord = function(word) { + this.dictionary.add(word); +}; + +/** + * @param {string} word + * @return {boolean} + */ +WordDictionary.prototype.search = function(word) { + if(word.includes('.')){ + const dictionaryList = [...this.dictionary]; + + return dictionaryList.some((dic) => { + if(dic.length !== word.length) return false; + + return [...dic].every((char, index) => word[index] === '.' ? true : word[index] === char) + }) + }; + + return this.dictionary.has(word) +}; + +/** + * Your WordDictionary object will be instantiated and called as such: + * var obj = new WordDictionary() + * obj.addWord(word) + * var param_2 = obj.search(word) + */