Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions 3sum/Yiseull.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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Sorting, Hash Map / Hash Set
  • 설명: 좌표의 정렬 후 두 포인터(left, right)를 이용해 합이 0인 세 수를 찾는 방식으로 구현되어 있습니다. 중복 제거를 위해 셋/정렬된 배열 이용과 포인터 이동 로직이 핵심 패턴입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n^2)
Space O(n)

피드백: 정렬 후 중복 제거를 위한 체크와 투 포인터 이동으로 불필요 연산을 피함. 결과를 집합으로 모아 중복 제거.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Solution:
def threeSum(self, nums: list[int]) -> list[list[int]]:
answer = set()

nums = sorted(nums)

n = len(nums)
for i in range(n - 2):
if nums[i] > 0:
break

if i > 0 and nums[i] == nums[i - 1]:
continue

left, right = i + 1, n - 1
while left < right:
threeSum = nums[i] + nums[left] + nums[right]
if threeSum < 0:
left += 1
elif threeSum == 0:
answer.add((nums[i], nums[left], nums[right]))
left += 1
right -= 1
else:
right -= 1

return list(answer)
11 changes: 11 additions & 0 deletions climbing-stairs/Yiseull.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.

공간 복잡도를 O(1)으로 최적화할 수 있을 것 같습니다!

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, Divide and Conquer
  • 설명: 높이 n일 때의 계단 수를 이전 두 값의 합으로 구하는 전형적인 DP 점화식 사용 패턴으로, 최적해를 하위 문제로 나눠 저장하는 방식이다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 동적 계획법으로 각 단계의 경우의 수를 저장해 재계산을 피함.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def climbStairs(self, n: int) -> int:
if n == 1: return 1

dp = [0 for _ in range(n + 1)]
dp[0], dp[1] = 1, 1

for i in range(2, n + 1):
dp[i] = dp[i - 1] + dp[i - 2]

return dp[n]
15 changes: 15 additions & 0 deletions product-of-array-except-self/Yiseull.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.

answer[0]을 1로 할당하니까 로직이 잘 읽히네요. 잘 봤습니다.

공간/시간 복잡도를 코드에 적어주시면 좋을 것 같아요!

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, Hash Map / Hash Set, Dynamic Programming, Greedy
  • 설명: 배열의 각 원소에 대해 왼쪽 곱과 오른쪽 곱을 누적해 전체 곱을 구하는 방식으로, 한 번의 왼쪽 누적과 한 번의 오른쪽 누적 순회를 이용하는 패턴이다. 공간 복잡도를 상향 없이 최적화하는 표준 DP/누적 곱 패턴이다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 추가 배열 없이 두 패스 합리적으로 사용하며, 나눗셈 없이도 해결 가능.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
n = len(nums)
answer = [1]

# answer[i] -> nums[i] 왼쪽 값들의 곱
for i in range(1, n):
answer.append(answer[i - 1] * nums[i - 1])

tmp = 1
for i in range(n - 1, -1, -1):

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.

개인적으로 저는 이렇게 작성하는거를 선호합니다!

for i in reversed(range(n)):

answer[i] *= tmp
tmp *= nums[i]

return answer
5 changes: 5 additions & 0 deletions valid-anagram/Yiseull.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.

파이썬의 언어적인 특성을 잘 활용하신 것 같습니다!

저는 성능에 도움이 될 것 같아서, 아래와 같이 길이가 다를 경우 얼리리턴을 해주었습니다. 참고 부탁드립니다~

if len(s) != len(t):
  return False

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set
  • 설명: 두 문자열의 문자 빈도를 해시 맵/카운터로 비교하는 방식으로 동등성 여부를 판단하므로 Hash Map / Hash Set 패턴에 해당합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(k)

피드백: Counter를 사용해 간결하고 정확하게 비교.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from collections import Counter

class Solution:
def isAnagram(self, s: str, t: str) -> bool:
return Counter(s) == Counter(t)
27 changes: 27 additions & 0 deletions validate-binary-search-tree/Yiseull.java

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search, Depth-First Search, Divide and Conquer
  • 설명: 이 코드는 BST의 특정 특성을 재귀적으로 확인하며, 각 서브트리에 대해 경계값을 두고(left, right) 재귀적으로 검사합니다. 재귀 방문은 DFS 형태이며, 각 노드가 허용 구역 내에 있는지 판단하는 과정을 통해 전체를 검증합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(h)

피드백: 각 노드를 방문하며 왼쪽은 작고 오른쪽은 커야 한다는 구간 조건을 유지.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
class Solution {
public boolean isValidBST(TreeNode root) {
return validate(root, null, null);
}

private boolean validate(TreeNode node, Integer low, Integer high) {
if (node == null) return true;
if (low != null && low >= node.val) return false;
if (high != null && high <= node.val) return false;
return validate(node.left, low, node.val) && validate(node.right, node.val, high);
}
}
Loading