From d39ddcdd73d9504c1f622fb0a9d994b6b66f097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=84=EC=A0=95?= Date: Sun, 3 Aug 2025 22:42:53 +0900 Subject: [PATCH 1/5] Add valid palindrome solution --- valid-palindrome/hyunjung-choi.kt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 valid-palindrome/hyunjung-choi.kt diff --git a/valid-palindrome/hyunjung-choi.kt b/valid-palindrome/hyunjung-choi.kt new file mode 100644 index 000000000..d96360468 --- /dev/null +++ b/valid-palindrome/hyunjung-choi.kt @@ -0,0 +1,9 @@ +import java.util.Locale.getDefault + +class Solution { + fun isPalindrome(s: String): Boolean { + if (s.isBlank()) return true + val cleanedString = s.trim().filter { it.isLetterOrDigit() }.lowercase(getDefault()) + return cleanedString == cleanedString.reversed() + } +} From ee4469d80abce17c3f79f6432f2f0df9296ffbd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=84=EC=A0=95?= Date: Mon, 4 Aug 2025 11:10:35 +0900 Subject: [PATCH 2/5] Add number of 1 bits solution --- number-of-1-bits/hyunjung-choi.kt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 number-of-1-bits/hyunjung-choi.kt diff --git a/number-of-1-bits/hyunjung-choi.kt b/number-of-1-bits/hyunjung-choi.kt new file mode 100644 index 000000000..d16916f1c --- /dev/null +++ b/number-of-1-bits/hyunjung-choi.kt @@ -0,0 +1,3 @@ +class Solution { + fun hammingWeight(n: Int) = Integer.bitCount(n) +} From 0f731bc38e0e7bcd2a00437d5f0072d37ba22c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=84=EC=A0=95?= Date: Tue, 5 Aug 2025 20:08:42 +0900 Subject: [PATCH 3/5] Add combination sum solution --- combination-sum/hyunjung-choi.kt | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 combination-sum/hyunjung-choi.kt diff --git a/combination-sum/hyunjung-choi.kt b/combination-sum/hyunjung-choi.kt new file mode 100644 index 000000000..615dc915b --- /dev/null +++ b/combination-sum/hyunjung-choi.kt @@ -0,0 +1,43 @@ +class Solution { + fun combinationSum(candidates: IntArray, target: Int): List> { + val result = mutableListOf>() + val currentCombination = mutableListOf() + + candidates.sort() + + backtrack(candidates, target, 0, currentCombination, result) + + return result + } + + private fun backtrack( + candidates: IntArray, + remainingTarget: Int, + startIndex: Int, + currentCombination: MutableList, + result: MutableList> + ) { + if (remainingTarget == 0) { + result.add(currentCombination.toList()) + return + } + + if (remainingTarget < 0) { + return + } + + for (i in startIndex until candidates.size) { + val candidate = candidates[i] + + if (candidate > remainingTarget) { + break + } + + currentCombination.add(candidate) + + backtrack(candidates, remainingTarget - candidate, i, currentCombination, result) + + currentCombination.removeAt(currentCombination.size - 1) + } + } +} From 40601bec2bd998abc83e028f15e0e1419c1ed3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=84=EC=A0=95?= Date: Wed, 6 Aug 2025 23:00:30 +0900 Subject: [PATCH 4/5] Add decode ways solution --- decode-ways/hyunjung-choi.kt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 decode-ways/hyunjung-choi.kt diff --git a/decode-ways/hyunjung-choi.kt b/decode-ways/hyunjung-choi.kt new file mode 100644 index 000000000..f77be775b --- /dev/null +++ b/decode-ways/hyunjung-choi.kt @@ -0,0 +1,27 @@ +class Solution { + fun numDecodings(s: String): Int { + if (s.isEmpty() || s[0] == '0') return 0 + + val n = s.length + val dp = IntArray(n + 1) + + dp[0] = 1 + dp[1] = 1 + + for (i in 2..n) { + val currentChar = s[i - 1] + val prevChar = s[i - 2] + + if (currentChar != '0') { + dp[i] += dp[i - 1] + } + + val twoDigit = (prevChar - '0') * 10 + (currentChar - '0') + if (twoDigit in 10..26) { + dp[i] += dp[i - 2] + } + } + + return dp[n] + } +} From abd7113f1d16c805d267068c6a6fba6ff3f20d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=84=EC=A0=95?= Date: Thu, 7 Aug 2025 16:02:38 +0900 Subject: [PATCH 5/5] Add maximum subarray solution --- maximum-subarray/hyunjung-choi.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 maximum-subarray/hyunjung-choi.kt diff --git a/maximum-subarray/hyunjung-choi.kt b/maximum-subarray/hyunjung-choi.kt new file mode 100644 index 000000000..d859d1014 --- /dev/null +++ b/maximum-subarray/hyunjung-choi.kt @@ -0,0 +1,13 @@ +class Solution { + fun maxSubArray(nums: IntArray): Int { + var currentSum = nums[0] + var maxSum = nums[0] + + for (i in 1 until nums.size) { + currentSum = if (currentSum < 0) nums[i] else currentSum + nums[i] + maxSum = maxOf(currentSum, maxSum) + } + + return maxSum + } +}