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
16 changes: 16 additions & 0 deletions climbing-stairs/tigermint.kt

@alphaorderly alphaorderly Jun 29, 2026

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)에 시간복잡도 O(LogN)까지 줄일수 있어요!
나중에 시도해보시는것도 좋겠네요
배열이 아니라 필요한 정보만 저장하는 방식을 통해 확실하게 공간복잡도 줄이는건 쉽게 하실수 있으실거에요

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
  • 설명: 클라이밍 스텝 문제는 현재 단계의 경우의 수를 이전 두 단계의 합으로 구하는 대표적인 DP 패턴이다. 배열에 상태를 저장하고 순차적으로 해결하는 형태다.

📊 시간/공간 복잡도 분석

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

피드백: dp 배열로 각 단계의 경우의 수를 저장해 반복적으로 갱신한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
fun climbStairs(n: Int): Int {
if (n == 1) return 1
if (n == 2) return 2

val dp = IntArray(n + 1) { 0 }
dp[1] = 1
dp[2] = 2

for (i in 3 .. n) {
dp[i] = dp[i - 1] + dp[i - 2]
}

return dp[n]
}
}
34 changes: 34 additions & 0 deletions product-of-array-except-self/tigermint.kt

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, Dynamic Programming
  • 설명: 양방향으로 누적 곱을 계산하는 풀이로, 왼쪽 누적 곱과 오른쪽 누적 곱을 합성해 결과를 구한다. 한 번의 순회로 왼쪽 곱, 역방향 순회로 오른쪽 곱을 반영하므로 두 포인터/양방향 누적의 패턴이 핵심이다.

📊 시간/공간 복잡도 분석

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

피드백: 추가 배열 없이 두 단계 누적 곱으로 결과를 계산한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// class Solution {
// fun productExceptSelf(nums: IntArray): IntArray {
// val prefixProduct = IntArray(nums.size) { _ -> 1 }
// val suffixProduct = IntArray(nums.size) { _ -> 1 }

// for (i in 1 until nums.size) {
// prefixProduct[i] = prefixProduct[i - 1] * nums[i - 1]
// }

// for (i in nums.size - 2 downTo 0) {
// suffixProduct[i] = suffixProduct[i + 1] * nums[i + 1]
// }

// return IntArray(nums.size) { prefixProduct[it] * suffixProduct[it] }
// }
// }

class Solution {
fun productExceptSelf(nums: IntArray): IntArray {
val answer = IntArray(nums.size) { _ -> 1 }

for (i in 1 until nums.size) {
answer[i] = answer[i - 1] * nums[i - 1]
}

var right = 1
for (i in nums.size - 1 downTo 0) {
answer[i] *= right
right *= nums[i]
}

return answer
}
}
20 changes: 20 additions & 0 deletions valid-anagram/tigermint.kt

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, Greedy
  • 설명: 두 문자열의 문자 빈도수를 맵에 기록하고, 두 맵의 키와 값 비교로 anagram 여부를 판단한다. 해시 맵/세트를 이용한 카운트 기반 비교 패턴이 핵심이며, 부분적으로 선형 시간 복잡도를 가진다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n + m)
Space O(K)

피드백: 두 맵의 키를 비교하고 각 문자 빈도를 점검한다.

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution {
fun isAnagram(s: String, t: String): Boolean {
val sCharToCount = mutableMapOf<Char, Int>()
val tCharToCount = mutableMapOf<Char, Int>()

s.forEach { sCharToCount[it] = (sCharToCount[it] ?: 0) + 1 }
t.forEach { tCharToCount[it] = (tCharToCount[it] ?: 0) + 1 }

val sKeys: MutableSet<Char> = sCharToCount.keys
val tKeys: MutableSet<Char> = tCharToCount.keys

if (sKeys != tKeys) return false
sKeys.forEach {
if (sCharToCount[it] != tCharToCount[it]) {
return false
}
}
return true
}
}
Loading