From 29891065e2bd0078daa95e8959428e8918a91850 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Wed, 19 Nov 2025 23:37:15 +0900 Subject: [PATCH 1/4] =?UTF-8?q?"longest-consecutive-sequence=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- longest-consecutive-sequence/ymir0804.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 longest-consecutive-sequence/ymir0804.java diff --git a/longest-consecutive-sequence/ymir0804.java b/longest-consecutive-sequence/ymir0804.java new file mode 100644 index 0000000000..459e1dbd1b --- /dev/null +++ b/longest-consecutive-sequence/ymir0804.java @@ -0,0 +1,36 @@ +import java.util.Collections; +import java.util.HashSet; + +/* + +*/ +class ymir0804 { + public int longestConsecutive(int[] nums) { + HashSet numsSet = new HashSet<>(); + int maxNum = 0; + for (int num: nums) { + numsSet.add(num); + } + + if(numsSet.isEmpty()) { + return 1; + } else if (numsSet.size() == 1) { + return 0; + } + + for (int num: numsSet) { + boolean isStartPoint = !numsSet.contains(num - 1); + if (isStartPoint) { + int current = num; + int length = 1; + while(numsSet.contains(++current)) { + length++; + } + if(length > maxNum) { + maxNum = length; + } + } + } + return maxNum; + } + } \ No newline at end of file From 2198bdc99d54d8e6f3f5b8339d6d58969234cf22 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Wed, 19 Nov 2025 23:37:36 +0900 Subject: [PATCH 2/4] =?UTF-8?q?"longest-consecutive-sequence=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- longest-consecutive-sequence/ymir0804.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/longest-consecutive-sequence/ymir0804.java b/longest-consecutive-sequence/ymir0804.java index 459e1dbd1b..c09f7b37a6 100644 --- a/longest-consecutive-sequence/ymir0804.java +++ b/longest-consecutive-sequence/ymir0804.java @@ -1,9 +1,5 @@ -import java.util.Collections; import java.util.HashSet; -/* - -*/ class ymir0804 { public int longestConsecutive(int[] nums) { HashSet numsSet = new HashSet<>(); From 4e5b3625a6e02bfbdde71bd37e520db48698e062 Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Fri, 21 Nov 2025 23:43:38 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20posix=20lint=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20house-robber=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- house-robber/ymir0804.java | 11 +++++++++++ longest-consecutive-sequence/ymir0804.java | 16 ++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 house-robber/ymir0804.java diff --git a/house-robber/ymir0804.java b/house-robber/ymir0804.java new file mode 100644 index 0000000000..1faa7077e1 --- /dev/null +++ b/house-robber/ymir0804.java @@ -0,0 +1,11 @@ +class Solution { + public int rob(int[] nums) { + int money = 0; + for (int i = 0; i < nums.length; i++) { + if (i % 2 == 0) { + money += nums[i]; + } + } + return money; + } +} diff --git a/longest-consecutive-sequence/ymir0804.java b/longest-consecutive-sequence/ymir0804.java index c09f7b37a6..e042024764 100644 --- a/longest-consecutive-sequence/ymir0804.java +++ b/longest-consecutive-sequence/ymir0804.java @@ -1,32 +1,32 @@ import java.util.HashSet; -class ymir0804 { +class Solution { public int longestConsecutive(int[] nums) { HashSet numsSet = new HashSet<>(); int maxNum = 0; - for (int num: nums) { + for (int num : nums) { numsSet.add(num); } - if(numsSet.isEmpty()) { + if (numsSet.isEmpty()) { return 1; } else if (numsSet.size() == 1) { return 0; } - for (int num: numsSet) { + for (int num : numsSet) { boolean isStartPoint = !numsSet.contains(num - 1); if (isStartPoint) { int current = num; int length = 1; - while(numsSet.contains(++current)) { + while (numsSet.contains(++current)) { length++; } - if(length > maxNum) { + if (length > maxNum) { maxNum = length; } } } return maxNum; - } - } \ No newline at end of file + } +} From d960abebcda411ae48a2fed9ca99ba6cf93ac52d Mon Sep 17 00:00:00 2001 From: ymir0804 Date: Fri, 21 Nov 2025 23:58:23 +0900 Subject: [PATCH 4/4] =?UTF-8?q?valid=20anagram=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- valid-anagram/ymir0804.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 valid-anagram/ymir0804.java diff --git a/valid-anagram/ymir0804.java b/valid-anagram/ymir0804.java new file mode 100644 index 0000000000..cdf6dc6ae9 --- /dev/null +++ b/valid-anagram/ymir0804.java @@ -0,0 +1,14 @@ +import java.util.Set; +import java.util.stream.Collectors; + +class Solution { + public boolean isAnagram(String s, String t) { + Set characterS = s.chars() + .mapToObj(c -> (char) c) + .collect(Collectors.toSet()); + Set characterT = t.chars() + .mapToObj(c -> (char) c) + .collect(Collectors.toSet()); + return characterS.equals(characterT); + } +}