From 17da13117cf4e34386fa5d82b37d9d58093f85c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8C=80=ED=98=84=20=28Kim=20DaeHyun=29?= Date: Mon, 20 Jul 2026 19:39:30 +0900 Subject: [PATCH 1/5] Solve: maxProfit --- best-time-to-buy-and-sell-stock/daehyun99.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 best-time-to-buy-and-sell-stock/daehyun99.py diff --git a/best-time-to-buy-and-sell-stock/daehyun99.py b/best-time-to-buy-and-sell-stock/daehyun99.py new file mode 100644 index 0000000000..74d2624862 --- /dev/null +++ b/best-time-to-buy-and-sell-stock/daehyun99.py @@ -0,0 +1,13 @@ +class Solution: + def maxProfit(self, prices: List[int]) -> int: + l = 0 + r = 0 + profit = 0 + + while r < len(prices): + if prices[l] < prices[r]: + profit = max(prices[r]-prices[l], profit) + elif prices[l] > prices[r]: + l = r + r += 1 + return profit From e956d7de1984435dc40d96c13f6390d4db0b1f01 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Tue, 21 Jul 2026 18:10:35 +0900 Subject: [PATCH 2/5] Solve: groupAnagrams --- group-anagrams/daehyun99.py | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 group-anagrams/daehyun99.py diff --git a/group-anagrams/daehyun99.py b/group-anagrams/daehyun99.py new file mode 100644 index 0000000000..1fcdb475cf --- /dev/null +++ b/group-anagrams/daehyun99.py @@ -0,0 +1,38 @@ +from collections import defaultdict +class Solution: + def groupAnagrams(self, strs: List[str]) -> List[List[str]]: + groups = defaultdict(list) + + for s in strs: + count = [0] * 26 + + for c in s: + count[ord(c)-ord('a')] += 1 + + groups[tuple(count)].append(s) + return list(groups.values()) + +""" +class Solution: + def groupAnagrams(self, strs: List[str]) -> List[List[str]]: + def decode(s, key, base): + for c in s: + key[ord(c) - base] += 1 + result = "" + for k in key: + result += ' ' + str(k) + return result + keys = {} + base_key = [0 for i in range(26)] + base = ord("a") + + for s in strs: + key = decode(s, base_key.copy(), base) + temp = keys.get(key, []) + temp.append(s) + keys[key] = temp + results = [] + for val in keys.values(): + results.append(val) + return results +""" From 662bccbc7e771ba1ef3c2eb66a0aadc513cccb90 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Thu, 23 Jul 2026 20:06:56 +0900 Subject: [PATCH 3/5] Solve: encode-and-decode --- encode-and-decode-strings/daehyun99.py | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 encode-and-decode-strings/daehyun99.py diff --git a/encode-and-decode-strings/daehyun99.py b/encode-and-decode-strings/daehyun99.py new file mode 100644 index 0000000000..cdebf17b3c --- /dev/null +++ b/encode-and-decode-strings/daehyun99.py @@ -0,0 +1,31 @@ +class Solution: + + def encode(self, strs: List[str]) -> str: + encoded_strs = "" + for s in strs: + encoded_strs += str(len(s)) + encoded_strs += "#" + for char in s: + encoded_strs += char + return encoded_strs + + def decode(self, s: str) -> List[str]: + print(s) + decoded_strs = [] + + idx = 0 + while idx < len(s): + end = idx + 1 + while s[end] != "#": + end += 1 + length = s[idx:end] + idx = end + decoded_str = "" + for i in range(int(length)): + idx += 1 + decoded_str += s[idx] + idx += 1 + decoded_strs.append(decoded_str) + return decoded_strs + + From 7d726616fc1b73b882314412f54ad364d431f715 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Fri, 24 Jul 2026 17:50:04 +0900 Subject: [PATCH 4/5] Solve: Trie --- implement-trie-prefix-tree/daehyun99.py | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 implement-trie-prefix-tree/daehyun99.py diff --git a/implement-trie-prefix-tree/daehyun99.py b/implement-trie-prefix-tree/daehyun99.py new file mode 100644 index 0000000000..c88af230f4 --- /dev/null +++ b/implement-trie-prefix-tree/daehyun99.py @@ -0,0 +1,43 @@ +class Trie: + def __init__(self): + self.root = dict() + + def insert(self, word: str) -> None: + pointer = self.root + for char in word: + if char in pointer: + pointer = pointer[char] + continue + else: + pointer[char] = dict() + pointer = pointer[char] + pointer[0] = dict() + + def search(self, word: str) -> bool: + pointer = self.root + for char in word: + if char in pointer: + pointer = pointer[char] + continue + else: + return False + if 0 in pointer: + return True + return False + + def startsWith(self, prefix: str) -> bool: + pointer = self.root + for char in prefix: + if char in pointer: + pointer = pointer[char] + continue + else: + return False + return True + + +# Your Trie object will be instantiated and called as such: +# obj = Trie() +# obj.insert(word) +# param_2 = obj.search(word) +# param_3 = obj.startsWith(prefix) From bfa58a6467eafd26166b10ba893632628dfbc5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8C=80=ED=98=84=20=28Kim=20DaeHyun=29?= Date: Sat, 25 Jul 2026 01:57:24 +0900 Subject: [PATCH 5/5] solve: wordBreak --- word-break/daehyun99.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 word-break/daehyun99.py diff --git a/word-break/daehyun99.py b/word-break/daehyun99.py new file mode 100644 index 0000000000..64ec706641 --- /dev/null +++ b/word-break/daehyun99.py @@ -0,0 +1,14 @@ +class Solution: + def wordBreak(self, s: str, wordDict: List[str]) -> bool: + pos = set() + pos.add(0) + len_s = len(s) + + while len(pos) > 0 : + l = pos.pop() + for word in wordDict: + if s[l:].startswith(word): + pos.add(l+len(word)) + if l == len_s: + return True + return False