import java.util.*;
class Solution {
public int[] solution(String s) {
List<String> list = new ArrayList<>();
if(!s.contains("},{")) {
return new int[]{Integer.parseInt(s.replace("{{","").replace("}}",""))};
}
String[] arr = s.split("\\}\\,\\{");
for(int i=0; i<arr.length; i++) {
arr[i] = arr[i].replace("{{","").replace("}}","");
}
Arrays.sort(arr, new Comparator<String>(){
@Override
public int compare(String s1, String s2) {
return s1.length()-s2.length();
}
});
int[] answer = new int[arr.length];
list.add(arr[0]); answer[0] = Integer.parseInt(arr[0]);
for(int i=1; i<answer.length; i++) {
String[] ss = arr[i].split(",");
for(String sss : ss) {
if(list.contains(sss)) { continue; }
list.add(sss); answer[i] = Integer.parseInt(sss);
break;
}
}
return answer;
}
}