From 9675dc55e1409a9491629ddd8478cd2e2f6b14e3 Mon Sep 17 00:00:00 2001 From: hoonji choi Date: Mon, 6 Jul 2026 16:53:19 -0700 Subject: [PATCH 1/3] valid-palindrom solution --- valid-palindrome/hoonjichoi1.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 valid-palindrome/hoonjichoi1.java diff --git a/valid-palindrome/hoonjichoi1.java b/valid-palindrome/hoonjichoi1.java new file mode 100644 index 0000000000..be60940a0e --- /dev/null +++ b/valid-palindrome/hoonjichoi1.java @@ -0,0 +1,23 @@ +class Solution { + public boolean isPalindrome(String s) { + + // removing all non-alphanumeric characters and convert them to lower case + String conveted = s.replaceAll("[^a-zA-Z0-9]", "").toLowerCase(); + + // early return of the empty string case + if (conveted.length() == 0) { + return true; + } + + // check the symmetry + int left = 0, right = conveted.length() - 1; + while (left <= right) { + if (conveted.charAt(left) != conveted.charAt(right)) { + return false; + } + left++; + right--; + } + return true; + } +} From c2fba06a6a9346ab0209bd34f1af606095149654 Mon Sep 17 00:00:00 2001 From: hoonji choi Date: Tue, 7 Jul 2026 14:43:23 -0700 Subject: [PATCH 2/3] number-of-1-bits solution --- number-of-1-bits/hoonjichoi1.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 number-of-1-bits/hoonjichoi1.java diff --git a/number-of-1-bits/hoonjichoi1.java b/number-of-1-bits/hoonjichoi1.java new file mode 100644 index 0000000000..7bc11fec2f --- /dev/null +++ b/number-of-1-bits/hoonjichoi1.java @@ -0,0 +1,19 @@ +class Solution { + public int hammingWeight(int n) { + + if (n == 1) { + return 1; + } + + int curr = n, result = 1; + while (curr > 1) { + if (curr % 2 == 1) { + result++; + } + curr = curr / 2; + } + + return result; + } +} + From b033da90723c3e43e6fbb891f05e2d18049083b5 Mon Sep 17 00:00:00 2001 From: hoonji choi Date: Wed, 8 Jul 2026 21:41:50 -0700 Subject: [PATCH 3/3] combination-sum solution --- combination-sum/hoonjichoi1.java | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 combination-sum/hoonjichoi1.java diff --git a/combination-sum/hoonjichoi1.java b/combination-sum/hoonjichoi1.java new file mode 100644 index 0000000000..00cd9d313b --- /dev/null +++ b/combination-sum/hoonjichoi1.java @@ -0,0 +1,35 @@ +/* +Time Complexity : O(c^t) +Space Complexity : O(t) + */ + +class Solution { + + public List> combinationSum(int[] candidates, int target) { + List> output = new ArrayList<>(); + Stack nums = new Stack<>(); + dfs (candidates, output, target, nums, 0, 0); + return output; + } + + private void dfs(int[] candidates, List> output, int target, Stack nums, int start, int total) { + // base case : pass + if (target == total) { + output.add(new ArrayList<>(nums)); + return; + } + // base case : fail + if (target < total) { + return; + } + + for (int i = start ; i < candidates.length ; i++) { + int num = candidates[i]; + nums.push(num); + dfs(candidates, output, target, nums, i, total + num); + nums.pop(); + } + + + } +}