From a7bd8cd1e6c5f30527c65cafd142f305693e6009 Mon Sep 17 00:00:00 2001 From: YOUNGJIN NA <120540450+ppxyn1@users.noreply.github.com> Date: Thu, 1 Jan 2026 20:19:59 +0900 Subject: [PATCH 1/2] [:solved] 2 problems --- palindromic-substrings/ppxyn1.py | 28 ++++++++++++++++++++++++++++ reverse-bits/ppxyn1.py | 10 ++++++++++ 2 files changed, 38 insertions(+) create mode 100644 palindromic-substrings/ppxyn1.py create mode 100644 reverse-bits/ppxyn1.py diff --git a/palindromic-substrings/ppxyn1.py b/palindromic-substrings/ppxyn1.py new file mode 100644 index 0000000000..0e25379a21 --- /dev/null +++ b/palindromic-substrings/ppxyn1.py @@ -0,0 +1,28 @@ +# idea : palindrome +# Time Complexity: O(n^2) + +class Solution: + def countSubstrings(self, s: str) -> int: + result = 0 + + for i in range(len(s)): + # odd + left = i + right = i + while left >= 0 and right < len(s) and s[left] == s[right]: + result += 1 + left -= 1 + right += 1 + + # even + left = i + right = i + 1 + while left >= 0 and right < len(s) and s[left] == s[right]: + result += 1 + left -= 1 + right += 1 + + return result + + + diff --git a/reverse-bits/ppxyn1.py b/reverse-bits/ppxyn1.py new file mode 100644 index 0000000000..dc1915028d --- /dev/null +++ b/reverse-bits/ppxyn1.py @@ -0,0 +1,10 @@ +# idea: - +# Time Complexity : O(1) since just fixed 32bit + +class Solution: + def reverseBits(self, n: int) -> int: + bits = bin(n)[2:] + bits = bits.zfill(32) # 32bits + reversed_bits = bits[::-1] + return int(reversed_bits, 2) # binary to int + From f841a9bb326cad99573842204ce1359a77bcaccb Mon Sep 17 00:00:00 2001 From: YOUNGJIN NA <120540450+ppxyn1@users.noreply.github.com> Date: Fri, 2 Jan 2026 19:24:53 +0900 Subject: [PATCH 2/2] [:solved] #274 --- longest-common-subsequence/ppxyn1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 longest-common-subsequence/ppxyn1.py diff --git a/longest-common-subsequence/ppxyn1.py b/longest-common-subsequence/ppxyn1.py new file mode 100644 index 0000000000..73fda73ec3 --- /dev/null +++ b/longest-common-subsequence/ppxyn1.py @@ -0,0 +1,18 @@ +# idea : recursive +# Time complexity : O(len(text1)*len(text2)) + +class Solution: + def longestCommonSubsequence(self, text1: str, text2: str) -> int: + @cache + def dfs(i, j): + if i == len(text1) or j == len(text2): + return 0 + if text1[i] == text2[j]: + match_len = 1 + dfs(i+1, j+1) + return match_len + else: + return max(dfs(i + 1, j), dfs(i, j + 1)) + return dfs(0, 0) + + +