Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions LiiNi-coder/202512/13 PGM 튜플.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;

class Solution {
public int[] solution(String s) {
s = s.substring(2, s.length() - 2);
String[] groups = s.split("}", "{");

Arrays.sort(groups, (a, b) -> a.length() - b.length());
Set<Integer> used = new HashSet<Integer>();
int[] answer = new int[groups.length];
int index = 0;
for(String group : groups){
String[] nums = group.split(",");
for(String num : nums){
int value = Integer.parseInt(num);
if(!used.contains(value)){
used.add(value);
answer[index++] = value;
break;
}
}
}
return answer;
}
}