From 93122adbd9600cc08b449a688f5b49d78ee4ca43 Mon Sep 17 00:00:00 2001 From: JeonJe <43032391+JeonJe@users.noreply.github.com> Date: Sun, 28 Jun 2026 23:59:41 +0900 Subject: [PATCH 1/4] valid anagram solution --- valid-anagram/JeonJe.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 valid-anagram/JeonJe.java diff --git a/valid-anagram/JeonJe.java b/valid-anagram/JeonJe.java new file mode 100644 index 0000000000..52446390f1 --- /dev/null +++ b/valid-anagram/JeonJe.java @@ -0,0 +1,21 @@ +import java.util.*; + +// TC: O(n) +// SC: O(1) +class Solution { + public boolean isAnagram(String s, String t) { + if (s.length() != t.length()) return false; + + int[] countS = new int[26]; + int[] countT = new int[26]; + for (int i = 0; i < s.length(); i++) { + countS[s.charAt(i) - 'a']++; + countT[t.charAt(i) - 'a']++; + } + + for (int i = 0; i < 26; i++) { + if (countS[i] != countT[i]) return false; + } + return true; + } +} From 5b2267685bbf577092e15d2fff1054346c3a053b Mon Sep 17 00:00:00 2001 From: JeonJe <43032391+JeonJe@users.noreply.github.com> Date: Mon, 29 Jun 2026 22:10:01 +0900 Subject: [PATCH 2/4] climbing stairs solution --- climbing-stairs/JeonJe.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 climbing-stairs/JeonJe.java diff --git a/climbing-stairs/JeonJe.java b/climbing-stairs/JeonJe.java new file mode 100644 index 0000000000..3308f8da68 --- /dev/null +++ b/climbing-stairs/JeonJe.java @@ -0,0 +1,31 @@ +import java.util.*; + +// TC: O(n) +// SC: O(n) +class Solution { + static int[] memo = new int[46]; + + + public int climbStairs(int n) { + + if (n == 1) return 1; + if (n == 2) return 2; + memo[1] = 1; + memo[2] = 2; + + dfs(n); + return memo[n]; + } + + private int dfs(int num) { + + //이미 계산한적이 있으면 + if (memo[num] != 0) { + return memo[num]; + } + + memo[num] = dfs(num - 1) + dfs(num - 2); + return memo[num]; + + } +} From 6398503d620994dd964e27df1e095545d6753eb6 Mon Sep 17 00:00:00 2001 From: JeonJe <43032391+JeonJe@users.noreply.github.com> Date: Tue, 30 Jun 2026 22:35:53 +0900 Subject: [PATCH 3/4] product of array except self solution --- product-of-array-except-self/JeonJe.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 product-of-array-except-self/JeonJe.java diff --git a/product-of-array-except-self/JeonJe.java b/product-of-array-except-self/JeonJe.java new file mode 100644 index 0000000000..811636ed4c --- /dev/null +++ b/product-of-array-except-self/JeonJe.java @@ -0,0 +1,22 @@ +import java.util.*; + +// TC: O(n) +// SC: O(1) +class Solution { + public int[] productExceptSelf(int[] nums) { + int n = nums.length; + + int[] answer = new int[n]; + answer[0] = 1; + for (int i = 1; i < n; i++) { + answer[i] = answer[i - 1] * nums[i - 1]; + } + + int right = 1; + for (int i = n - 2; i >= 0; i--) { + right = right * nums[i + 1]; + answer[i] = answer[i] * right; + } + return answer; + } +} From 9581f845e9b6c7d6321048e7e363c14958ec6939 Mon Sep 17 00:00:00 2001 From: JeonJe <43032391+JeonJe@users.noreply.github.com> Date: Wed, 1 Jul 2026 21:45:44 +0900 Subject: [PATCH 4/4] 3sum solution --- 3sum/JeonJe.java | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 3sum/JeonJe.java diff --git a/3sum/JeonJe.java b/3sum/JeonJe.java new file mode 100644 index 0000000000..1c06e33978 --- /dev/null +++ b/3sum/JeonJe.java @@ -0,0 +1,41 @@ +import java.util.*; + +// TC: O(n^2) +// SC: O(1) +class Solution { + + public List> threeSum(int[] nums) { + + List> answer = new ArrayList<>(); + int n = nums.length; + Arrays.sort(nums); + + for (int x = 0; x < n - 2; x++) { + if (x > 0 && nums[x] == nums[x - 1]) continue; + + int left = x + 1; + int right = n - 1; + + while (left < right) { + if (nums[left] + nums[right] + nums[x] == 0) { + answer.add(Arrays.asList(nums[x], nums[left], nums[right])); + + while (left + 1 < right && nums[left] == nums[left + 1]) { + left++; + } + while (left < right - 1 && nums[right] == nums[right - 1]) { + right--; + } + left++; + right--; + } else if (nums[left] + nums[right] + nums[x] < 0) { + left++; + } else { + right--; + } + } + } + + return answer; + } +}