From 9658082dd4f18ec0342d1c294da230bb5bc17672 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Tue, 9 Dec 2025 16:57:14 +0900 Subject: [PATCH 1/3] =?UTF-8?q?3Sum=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3sum/ymir0804.java | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 3sum/ymir0804.java diff --git a/3sum/ymir0804.java b/3sum/ymir0804.java new file mode 100644 index 000000000..240420d67 --- /dev/null +++ b/3sum/ymir0804.java @@ -0,0 +1,39 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +class Solution { + public List> threeSum(int[] nums) { + List> answer = new ArrayList<>(); + Arrays.sort(nums); + int sum = 0; + + for (int i = 0; i < nums.length-2; i++) { + int left = i + 1; + int right = nums.length -1; + if(i > 0 && nums[i-1] == nums[i]) { + continue; + } + while (left < right ) { + sum = nums[i] + nums[left] + nums[right]; + if(sum > 0) { + right--; + } else if(sum < 0 ) { + left++; + } else { + answer.add(Arrays.asList(nums[i], nums[left], nums[right])); + while (left < right && nums[left] == nums[left + 1]) { + left++; + } + while (left < right && nums[right] == nums[right - 1]) { + right--; + } + left++; + right--; + } + } + + } + return answer; + } +} From 8261cc5e8c1b769c685e48920ac3ea4d8b7ed9f9 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Tue, 9 Dec 2025 17:58:35 +0900 Subject: [PATCH 2/3] =?UTF-8?q?validate=20binary=20search=20tree=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- validate-binary-search-tree/ymir0804.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 validate-binary-search-tree/ymir0804.java diff --git a/validate-binary-search-tree/ymir0804.java b/validate-binary-search-tree/ymir0804.java new file mode 100644 index 000000000..5384ab8fd --- /dev/null +++ b/validate-binary-search-tree/ymir0804.java @@ -0,0 +1,15 @@ +class Solution { + public boolean isValidBST(TreeNode root) { + return isValid(root, Long.MIN_VALUE, Long.MAX_VALUE); + } + public boolean isValid(TreeNode node, long min, long max) { + if (node == null) { + return true; + } + if (node.val <= min || node.val >= max) { + return false; + } + return isValid(node.left, min, node.val) && isValid(node.right, node.val, max); + } + +} \ No newline at end of file From 5cb9b9762a7d57f74af0e7256d78a283720e20f4 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Sun, 14 Dec 2025 17:28:55 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20lint=EB=A5=BC=20=EC=9C=84=ED=95=B4?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- validate-binary-search-tree/ymir0804.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validate-binary-search-tree/ymir0804.java b/validate-binary-search-tree/ymir0804.java index 5384ab8fd..18d46167a 100644 --- a/validate-binary-search-tree/ymir0804.java +++ b/validate-binary-search-tree/ymir0804.java @@ -12,4 +12,5 @@ public boolean isValid(TreeNode node, long min, long max) { return isValid(node.left, min, node.val) && isValid(node.right, node.val, max); } -} \ No newline at end of file +} +