Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4836151
contains duplicate solution
yuseok89 Jun 23, 2026
cdc00da
two sum solution
yuseok89 Jun 23, 2026
cc0a988
top k frequent elements solution
yuseok89 Jun 23, 2026
c894055
longest consecutive sequence solution
yuseok89 Jun 23, 2026
4e4e412
house robber solution
yuseok89 Jun 23, 2026
32cafb9
add newline
yuseok89 Jun 23, 2026
49ecb59
리뷰 반영
yuseok89 Jun 25, 2026
a6fcc33
리뷰 반영
yuseok89 Jun 25, 2026
38a1f67
개선 - AI assist
yuseok89 Jun 25, 2026
8bd5a32
valid anagram solution
yuseok89 Jun 29, 2026
05685ed
Merge branch 'DaleStudy:main' into main
yuseok89 Jun 29, 2026
cd23e34
climbing stairs solution
yuseok89 Jun 29, 2026
120df1f
product of array except self solution
yuseok89 Jul 1, 2026
1d4ff54
3sum solution
yuseok89 Jul 1, 2026
23142a7
validate binary search tree solution
yuseok89 Jul 1, 2026
0cb14ca
공간복잡도 업데이트
yuseok89 Jul 1, 2026
9465142
공간복잡도 업데이트
yuseok89 Jul 1, 2026
8b4a01f
Merge branch 'DaleStudy:main' into main
yuseok89 Jul 7, 2026
4b09054
validate palindrome solution
yuseok89 Jul 7, 2026
da3aad9
number of 1 bits solution
yuseok89 Jul 7, 2026
5c4d5fb
combination sum solution
yuseok89 Jul 7, 2026
03f3f1a
decode ways solution
yuseok89 Jul 7, 2026
d8d5ea4
maximum subarray solution
yuseok89 Jul 7, 2026
1f003e2
복잡도 업데이트
yuseok89 Jul 7, 2026
a022d10
재귀 로직 개선
yuseok89 Jul 9, 2026
b8248c4
maximum subarray 풀이 개선
yuseok89 Jul 9, 2026
51c1012
valid palindrome 풀이 개선
yuseok89 Jul 9, 2026
65431c0
maximum subarray 풀이 개선
yuseok89 Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions combination-sum/yuseok89.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다 좋으신데, 백트래킹 부분이 너무 복잡한거 같아요
별도의 함수로 제외하지 않고 구현하시면 훨씬 보기 좋게 될거 같아요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

백트래킹 코드를 좀 더 보기좋게 수정했습니다.
별도의 함수로 빼지 않고 구현은 어떤 방식을 말하시는걸까요?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Backtracking, Depth-First Search
  • 설명: 이 코드는 후보 배열에서 재귀적으로 모든 조합을 탐색하며, 합이 목표와 같아지면 해를 추가하고, 각 후보를 다시 재귀 호출하는 구조로 Backtracking 패턴을 사용합니다. DFS 방식으로 트리 형태의 탐색 공간을 탐색합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(k * C)
Space O(k)

피드백: 재귀 깊이가 후보 배열의 길이에 따라 달라지며, 중복 제거 없이 같은 원소를 여러 번 뽑을 수 있도록 구현되어 있다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# TC: O(N^T)
# SC: O(T)
class Solution:

def rec(self, cur_idx, target, candi, cur_combi, ans):

if target == 0:
ans.append(cur_combi.copy())

if cur_idx == len(candi):
return

for idx in range(cur_idx, len(candi)):
if target < candi[idx]:
continue

cur_combi.append(candi[idx])
self.rec(idx, target - candi[idx], candi, cur_combi, ans)
cur_combi.pop()

def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:

ans = []

self.rec(0, target, candidates, [], ans)

return ans

29 changes: 29 additions & 0 deletions decode-ways/yuseok89.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming, Backtracking
  • 설명: 문제는 문자열 디코딩 방법의 개수를 DP로 점화식으로 계산합니다. 재귀 함수에 메모이제이션을 사용해 중복 계산을 줄이며, 부분 문제를 합쳐 최종 해를 구하는 구조입니다.

📊 시간/공간 복잡도 분석

ℹ️ 이 파일에는 2가지 풀이가 포함되어 있어 각각 분석합니다.

풀이 1: Solution.numDecodings — Time: O(n) / Space: O(n)
복잡도
Time O(n)
Space O(n)

피드백: 상태 수를 줄여 중복 계산을 제거했지만, 재귀 대신 배열 기반 반복으로도 구현 가능하다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 2: Solution.rec — Time: O(n) / Space: O(n)
복잡도
Time O(n)
Space O(n)

피드백: 입력 길이에 선형적으로 의존하는 동적계획으로 구성되어 있다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# TC: O(N)
# SC: O(N)
class Solution:

memo = []

def rec(self, idx, s, n):
if self.memo[idx] == -1:

cnt = 0

if int(s[idx]) != 0:
cnt += self.rec(idx + 1, s, n)

if idx + 1 < n:
if int(s[idx]) != 0 and int(s[idx]) * 10 + int(s[idx + 1]) <= 26:
cnt += self.rec(idx + 2, s, n)

self.memo[idx] = cnt

return self.memo[idx]

def numDecodings(self, s: str) -> int:

self.memo = [-1] * (len(s) + 1)
self.memo[len(s)] = 1

return self.rec(0, s, len(s))

24 changes: 24 additions & 0 deletions maximum-subarray/yuseok89.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아주 개인적인 의견으로는

  1. for loop안의 if-else 부분도 max로 한줄로 깔끔하게 정리하면 보기 좋을것 같아요!
  2. sum과 ans를 nums[0]으로 설정하셨는데 for loop도 0번 index부터 시작하는건 중복 검사 같네요, 1번 index부터 검사하시는게 로직상 맞지 않을까 하는 생각이 듭니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 그렇네요. 의견 감사합니다
  2. 이터레이터 방식이 아무래도 성능 면에서 나아서 그렇게 구현했네요. 처음 sum 값을 중복을 고려해 넣어두어서, 로직상 틀렸다고 하기에는 어려운 것 같아요. 그래도 덕분에 이터레이터 방식을 유지하면서도 1번 index 부터 확인하는 방법을 고민해 보았네요. 감사합니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Greedy, Dynamic Programming
  • 설명: 배열을 순회하며 부분 배열의 합을 최적화하는 Kadane 알고리즘으로, 현재 위치의 값과 이전 합의 합을 비교해 누적 합을 갱신하는 관점은 그리디 성격과 DP 점화식의 핵심을 모두 보여줍니다.

📊 시간/공간 복잡도 분석

ℹ️ 이 파일에는 2가지 풀이가 포함되어 있어 각각 분석합니다.

풀이 1: Solution.maxSubArray — Time: ✅ O(N) → O(n) / Space: ✅ O(1) → O(1)
유저 분석 실제 분석 결과
Time O(N) O(n)
Space O(1) O(1)

피드백: 4줄짜리 간결한 구현으로 최적의 시간/공간 복잡도를 달성한다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 2: Solution.maxSubArray (주석 대안) — Time: O(n) / Space: O(1)
복잡도
Time O(n)
Space O(1)

피드백: 주석은 실행에 영향 없이 대안을 보여준다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# TC: O(N)
# SC: O(1)
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
sum = nums[0]
ans = sum

for num in nums[1:]:
sum = max(num, sum + num)
ans = max(ans, sum)

return ans

# class Solution:
# def maxSubArray(self, nums: List[int]) -> int:
# sum = nums[0] if nums[0] < 0 else 0
# ans = sum

# for num in nums:
# sum = max(num, sum + num)
# ans = max(ans, sum)

# return ans

13 changes: 13 additions & 0 deletions number-of-1-bits/yuseok89.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔하게 잘 해결하신거 같아요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Bit Manipulation
  • 설명: 주어진 코드는 정수의 이진 표현에서 1의 개수를 세는 방식으로, 비트를 직접 다루는 비트 조작 패턴에 해당합니다. 반복문으로 각 비트를 검사하며 1의 개수를 누적합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(logN) O(n)
Space O(1) O(1)

피드백: 입력 정수의 비트 수에 비례하는 선형 시간, 상수 공간이다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# TC: O(logN)
# SC: O(1)
class Solution:
def hammingWeight(self, n: int) -> int:

cnt = 0

while n > 0:
cnt = cnt + (n % 2)
n //= 2

return cnt

43 changes: 43 additions & 0 deletions valid-palindrome/yuseok89.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 풀이는 Immutable 한 string을 하나 더 만들기 때문에 O(N)의 공간복잡도를 가질거에요!
설명
regex없이 two pointer로 접근해보시는것도 좋은 경험이 되실겁니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞네요. 일단 이 문제는 투포인터로 접근하는게 맞을 것 같습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Greedy
  • 설명: 문자열을 앞뒤에서 포인터로 이동하며 유효 문자만 비교하는 흐름은 Two Pointers 패턴에 해당합니다. 또한 대칭 비교로 판별하는 구조는 간단한 조건 판단으로 끝나므로 그 자체로 Greedy의 직관적 판단과도 연결됩니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(N) O(n)
Space O(1) O(1)

피드백: 대소문자 무시 및 비문자 제거를 한 단일 패스로 검사한다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# TC: O(N)
# SC: O(1)
class Solution:

def is_alphanum(self, c):
return 'a' <= c <= 'z' or '0' <= c <= '9'

def isPalindrome(self, s: str) -> bool:

left = 0
right = len(s) - 1

s = s.lower()

while(left < right):
while left < len(s) and not self.is_alphanum(s[left]):
left += 1
while right >= 0 and not self.is_alphanum(s[right]):
right -= 1

if left < right and s[left] != s[right]:
return False

left += 1
right -= 1

return True

# class Solution:
# def isPalindrome(self, s: str) -> bool:
#
# import re
#
# s = re.sub(r'[^a-zA-Z0-9]', '', s.lower())
#
# n = len(s)
#
# for idx in range(0, n // 2):
# if s[idx] != s[n - idx - 1]:
# return False
#
# return True

Loading