From 03f0f27f3fe99f35d316ffdfd53574cdb6d8bd9f Mon Sep 17 00:00:00 2001 From: renovizee Date: Sun, 27 Jul 2025 19:23:01 +0900 Subject: [PATCH 1/5] feat: Set up Week 2 problems Adds the initial boilerplate files for the week 2 problems, including: - Valid Anagram (Easy) - Climbing Stairs (Easy) - Product of Array Except Self (Medium) - 3Sum (Medium) - Validate Binary Search Tree (Medium) --- 3sum/renovizee.java | 19 +++++++++++ climbing-stairs/renovizee.java | 17 ++++++++++ product-of-array-except-self/renovizee.java | 18 +++++++++++ valid-anagram/renovizee.java | 18 +++++++++++ validate-binary-search-tree/renovizee.java | 35 +++++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 3sum/renovizee.java create mode 100644 climbing-stairs/renovizee.java create mode 100644 product-of-array-except-self/renovizee.java create mode 100644 valid-anagram/renovizee.java create mode 100644 validate-binary-search-tree/renovizee.java diff --git a/3sum/renovizee.java b/3sum/renovizee.java new file mode 100644 index 000000000..74bc5b637 --- /dev/null +++ b/3sum/renovizee.java @@ -0,0 +1,19 @@ +import java.util.List; + + +// tag renovizee 2week unresolved +// https://github.com/DaleStudy/leetcode-study/issues/241 +// https://leetcode.com/problems/3sum/ +class Solution { + // Solv1 : + // 시간복잡도 : O(n) + // 공간복잡도 : O(n) + public List> threeSum(int[] nums) { + + } +} + +//------------------------------------------------------------------------------------------------------------- +// Java 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/climbing-stairs/renovizee.java b/climbing-stairs/renovizee.java new file mode 100644 index 000000000..79f088331 --- /dev/null +++ b/climbing-stairs/renovizee.java @@ -0,0 +1,17 @@ + + +// tag renovizee 2week +// https://github.com/DaleStudy/leetcode-study/issues/230 +// https://leetcode.com/problems/climbing-stairs/ #70 #Easy +class Solution { + // Solv1 : + // 시간복잡도 : O(n) + // 공간복잡도 : O(n) + public int climbStairs(int n) { + + } +} +//------------------------------------------------------------------------------------------------------------- +// Java 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/product-of-array-except-self/renovizee.java b/product-of-array-except-self/renovizee.java new file mode 100644 index 000000000..7c3bdc1b6 --- /dev/null +++ b/product-of-array-except-self/renovizee.java @@ -0,0 +1,18 @@ + + +// tag renovizee 2week +// https://github.com/DaleStudy/leetcode-study/issues/239 +// https://leetcode.com/problems/product-of-array-except-self/ +class Solution { + // Solv1 : + // 시간복잡도 : O(n) + // 공간복잡도 : O(n) + public int[] productExceptSelf(int[] nums) { + + } +} + +//------------------------------------------------------------------------------------------------------------- +// Java 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/valid-anagram/renovizee.java b/valid-anagram/renovizee.java new file mode 100644 index 000000000..43afb6ef8 --- /dev/null +++ b/valid-anagram/renovizee.java @@ -0,0 +1,18 @@ + + +// tag renovizee 2week +// https://github.com/DaleStudy/leetcode-study/issues/218 +// https://leetcode.com/problems/valid-anagram/ #242 #Easy +class Solution { + // Solv1 : + // 시간복잡도 : O(n) + // 공간복잡도 : O(n) + public boolean isAnagram(String s, String t) { + + } +} + +//------------------------------------------------------------------------------------------------------------- +// Java 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- diff --git a/validate-binary-search-tree/renovizee.java b/validate-binary-search-tree/renovizee.java new file mode 100644 index 000000000..19c72707d --- /dev/null +++ b/validate-binary-search-tree/renovizee.java @@ -0,0 +1,35 @@ + + +// tag renovizee 2week +// https://github.com/DaleStudy/leetcode-study/issues/251 +// https://leetcode.com/problems/validate-binary-search-tree/ +class Solution { + + /** + * 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; + * } + * } + */ + + // Solv1 : + // 시간복잡도 : O(n) + // 공간복잡도 : O(n) + public boolean isValidBST(TreeNode root) { + + } +} + +//------------------------------------------------------------------------------------------------------------- +// Java 문법 피드백 +// +//------------------------------------------------------------------------------------------------------------- From 7db66ddd7b9e158efba65cf1f96f08f7c7601f06 Mon Sep 17 00:00:00 2001 From: renovizee Date: Sun, 27 Jul 2025 19:23:15 +0900 Subject: [PATCH 2/5] =?UTF-8?q?docs:=201=EC=A3=BC=EC=B0=A8=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=EC=97=90=20=EC=B0=BE=EA=B8=B0=20=ED=8E=B8=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20name=20tag=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- house-robber/renovizee.java | 2 ++ top-k-frequent-elements/renovizee.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/house-robber/renovizee.java b/house-robber/renovizee.java index 85f796d42..a3c358b74 100644 --- a/house-robber/renovizee.java +++ b/house-robber/renovizee.java @@ -1,6 +1,8 @@ +// tag renovizee 1week unresolved // https://github.com/DaleStudy/leetcode-study/issues/264 // https://leetcode.com/problems/house-robber/ +// DP 자체에 대한 설명 : https://www.youtube.com/watch?v=0bqfTzpWySY class Solution { public int rob(int[] nums) { diff --git a/top-k-frequent-elements/renovizee.java b/top-k-frequent-elements/renovizee.java index 214c3d817..3c115e4c5 100644 --- a/top-k-frequent-elements/renovizee.java +++ b/top-k-frequent-elements/renovizee.java @@ -1,7 +1,9 @@ +// tag renovizee 1week unresolved // https://github.com/DaleStudy/leetcode-study/issues/237 // https://leetcode.com/problems/top-k-frequent-elements/ class Solution { + public int[] topKFrequent(int[] nums, int k) { int[] result = {1, 2, 3}; From 6ed60b9906b1f5fd75194cc56e0f12b025ace56c Mon Sep 17 00:00:00 2001 From: renovizee Date: Sun, 27 Jul 2025 20:38:21 +0900 Subject: [PATCH 3/5] feat(leetcode/242): Solve Valid Anagram (Easy) --- valid-anagram/renovizee.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/valid-anagram/renovizee.java b/valid-anagram/renovizee.java index 43afb6ef8..412e75a05 100644 --- a/valid-anagram/renovizee.java +++ b/valid-anagram/renovizee.java @@ -1,18 +1,27 @@ - +import java.util.Arrays; // tag renovizee 2week // https://github.com/DaleStudy/leetcode-study/issues/218 // https://leetcode.com/problems/valid-anagram/ #242 #Easy class Solution { - // Solv1 : + // Solv1 // 시간복잡도 : O(n) // 공간복잡도 : O(n) public boolean isAnagram(String s, String t) { + char[] sChars = s.toCharArray(); + char[] tChars = t.toCharArray(); + + Arrays.sort(sChars); + Arrays.sort(tChars); + + return Arrays.equals(sChars, tChars); } } //------------------------------------------------------------------------------------------------------------- // Java 문법 피드백 -// +// 1) string.toCharArray +// 2) Arrays.~ 문법 ~.sort ~.equals +// 3) Arrays. //------------------------------------------------------------------------------------------------------------- From 7aef46c83b844f1aea717a78cad2ff9fcfe67a4b Mon Sep 17 00:00:00 2001 From: renovizee Date: Sun, 27 Jul 2025 22:54:13 +0900 Subject: [PATCH 4/5] feat(leetcode/70): Climbing Stairs (Easy) --- climbing-stairs/renovizee.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/climbing-stairs/renovizee.java b/climbing-stairs/renovizee.java index 79f088331..caa20a731 100644 --- a/climbing-stairs/renovizee.java +++ b/climbing-stairs/renovizee.java @@ -1,17 +1,35 @@ + // tag renovizee 2week // https://github.com/DaleStudy/leetcode-study/issues/230 // https://leetcode.com/problems/climbing-stairs/ #70 #Easy class Solution { - // Solv1 : + // Solv1 // 시간복잡도 : O(n) // 공간복잡도 : O(n) public int climbStairs(int n) { + int[] dp = new int[]{1, 2}; + + if (n == dp[0]) { + return dp[0]; + } + + if (n == dp[1]) { + return dp[1]; + } + + for (int i = 3; i <= n; i++) { + int nextWayCount = dp[0] + dp[1]; + dp[0] = dp[1]; + dp[1] = nextWayCount; + } + + return dp[1]; } } //------------------------------------------------------------------------------------------------------------- // Java 문법 피드백 -// +// 1) Math.pow(2, 3) 2의 3승. //------------------------------------------------------------------------------------------------------------- From eca2f027f5f4d0a119f3569ced1c7328109c8015 Mon Sep 17 00:00:00 2001 From: renovizee Date: Sun, 27 Jul 2025 23:17:37 +0900 Subject: [PATCH 5/5] feat(leetcode/238): Product of Array Except Self (Medium) --- product-of-array-except-self/renovizee.java | 33 ++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/product-of-array-except-self/renovizee.java b/product-of-array-except-self/renovizee.java index 7c3bdc1b6..1bf09d501 100644 --- a/product-of-array-except-self/renovizee.java +++ b/product-of-array-except-self/renovizee.java @@ -2,14 +2,45 @@ // tag renovizee 2week // https://github.com/DaleStudy/leetcode-study/issues/239 -// https://leetcode.com/problems/product-of-array-except-self/ +// https://leetcode.com/problems/product-of-array-except-self/ #238 #Medium class Solution { // Solv1 : // 시간복잡도 : O(n) // 공간복잡도 : O(n) public int[] productExceptSelf(int[] nums) { + boolean isZero = false; + int zeroIndex = 0; + + int productExceptZero = 1; + for (int i = 0; i < nums.length; i++) { + if (nums[i] == 0) { + if (isZero) { // zero가 2개면 모든 원소가 0임. + return new int[nums.length]; + } + zeroIndex = i; + isZero = true; + } else { + productExceptZero *= nums[i]; + } + } + + int[] result = new int[nums.length]; + for (int i = 0; i < nums.length; i++) { + if (isZero) { + if (i != zeroIndex) { + result[i] = 0; + } else { + result[i] = productExceptZero; + } + } else { + result[i] = productExceptZero / nums[i]; + } + + } + return result; } + } //-------------------------------------------------------------------------------------------------------------