We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 569e37d + 10f1d00 commit ef8da4dCopy full SHA for ef8da4d
LiiNi-coder/202512/13 PGM 튜플.md
@@ -0,0 +1,25 @@
1
+import java.util.*;
2
+
3
+class Solution {
4
+ public int[] solution(String s) {
5
+ s = s.substring(2, s.length() - 2);
6
+ String[] groups = s.split("}", "{");
7
8
+ Arrays.sort(groups, (a, b) -> a.length() - b.length());
9
+ Set<Integer> used = new HashSet<Integer>();
10
+ int[] answer = new int[groups.length];
11
+ int index = 0;
12
+ for(String group : groups){
13
+ String[] nums = group.split(",");
14
+ for(String num : nums){
15
+ int value = Integer.parseInt(num);
16
+ if(!used.contains(value)){
17
+ used.add(value);
18
+ answer[index++] = value;
19
+ break;
20
+ }
21
22
23
+ return answer;
24
25
+}
0 commit comments