From eca045ca87d866c5edf3420c77d1619c3a1bfb28 Mon Sep 17 00:00:00 2001 From: hyeonji0108 Date: Tue, 3 Nov 2026 23:21:02 +0900 Subject: [PATCH 1/3] Create 49. Group Anagrams --- .../49. Group Anagrams" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "leetcode3/\352\263\275\355\230\204\354\247\200/49. Group Anagrams" diff --git "a/leetcode3/\352\263\275\355\230\204\354\247\200/49. Group Anagrams" "b/leetcode3/\352\263\275\355\230\204\354\247\200/49. Group Anagrams" new file mode 100644 index 00000000..e54a5d87 --- /dev/null +++ "b/leetcode3/\352\263\275\355\230\204\354\247\200/49. Group Anagrams" @@ -0,0 +1,42 @@ +[문제내용] +Example 1: + +Input: strs = ["eat","tea","tan","ate","nat","bat"] + +Output: [["bat"],["nat","tan"],["ate","eat","tea"]] + +Explanation: + +There is no string in strs that can be rearranged to form "bat". +The strings "nat" and "tan" are anagrams as they can be rearranged to form each other. +The strings "ate", "eat", and "tea" are anagrams as they can be rearranged to form each other. +Example 2: + +Input: strs = [""] + +Output: [[""]] + +Example 3: + +Input: strs = ["a"] + +Output: [["a"]] + + +[작성한 코드답안] +class Solution { + public List> groupAnagrams(String[] strs) { + Map> answer = new HashMap<>(); + for(String str : strs) { + // 문자 나열 + char[] c = str.toCharArray(); + Arrays.sort(c); // 나열한 문자 정렬 + String s = String.valueOf(c); + + if(!answer.containsKey(s)) + answer.put(s, new ArrayList<>()); + answer.get(s).add(str); + } + return new ArrayList<>(answer.values()); + } +} From 975298185c2e01eeab21cdb678d76259f382affd Mon Sep 17 00:00:00 2001 From: hyeonji0108 Date: Tue, 3 Nov 2026 23:21:48 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Create=20=20=EC=95=94=ED=98=B8=20=20=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=EC=8B=9C=ED=97=98=20=EA=B2=B0=EA=B3=BC=2015.=203Sum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...227\230 \352\262\260\352\263\274 15. 3Sum" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" diff --git "a/leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" "b/leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" new file mode 100644 index 00000000..25f8495a --- /dev/null +++ "b/leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" @@ -0,0 +1,47 @@ +[문제내용] +Example 1: + +Input: nums = [-1,0,1,2,-1,-4] +Output: [[-1,-1,2],[-1,0,1]] +Explanation: +nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0. +nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0. +nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0. +The distinct triplets are [-1,0,1] and [-1,-1,2]. +Notice that the order of the output and the order of the triplets does not matter. +Example 2: + +Input: nums = [0,1,1] +Output: [] +Explanation: The only possible triplet does not sum up to 0. +Example 3: + +Input: nums = [0,0,0] +Output: [[0,0,0]] +Explanation: The only possible triplet sums up to 0. + + +[작성한 답안] +class Solution { + public List> threeSum(int[] nums) { + List> result = new ArrayList<>(); + + Arrays.sort(nums); + + for (int i = 0; i < nums.length - 2; i++) { + int left = i + 1; + int right = nums.length - 1; + + while (left < right) { + int sum = nums[i] + nums[left] + nums[right]; + + // 세 수의 합이 0일 때 출력 + if (sum == 0) { + result.add(Arrays.sort(nums[i], nums[left], nums[right])); + } else { + break; + } + } + } + } +} From f0f212cf6ec58f534405b8ce8278a45b5401b4b1 Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 3 Nov 2026 23:22:57 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Rename=20=EC=95=94=ED=98=B8=20=20=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=EC=8B=9C=ED=97=98=20=EA=B2=B0=EA=B3=BC=2015.=203Sum=20to=2015.?= =?UTF-8?q?=203Sum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\352\263\275\355\230\204\354\247\200/15. 3Sum" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" => "leetcode3/\352\263\275\355\230\204\354\247\200/15. 3Sum" (100%) diff --git "a/leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" "b/leetcode3/\352\263\275\355\230\204\354\247\200/15. 3Sum" similarity index 100% rename from "leetcode3/\352\263\275\355\230\204\354\247\200/\354\225\224\355\230\270 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \355\205\214\354\212\244\355\212\270 \354\274\200\354\235\264\354\212\244 \354\213\234\355\227\230 \352\262\260\352\263\274 15. 3Sum" rename to "leetcode3/\352\263\275\355\230\204\354\247\200/15. 3Sum"