import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedHashSet;
public class Tuple {
public int[] solution(String s) {
ArrayList<Integer> list = new ArrayList<>();
LinkedHashSet<String> set = new LinkedHashSet<>();
String[] str = s.substring(1, s.length() - 1).split("},");
Arrays.sort(str, new Comparator<String>() {
public int compare(String s1, String s2) {
if (s1.length() > s2.length()) {
return 1;
} else if (s1.length() < s2.length()) {
return -1;
} else {
return 0;
}
}
});
for (int i = 0; i < str.length; i++) {
String temp = "";
for (int j = 0; j < str[i].length(); j++) {
if (str[i].charAt(j) >= '0' && str[i].charAt(j) <= '9') {
temp += str[i].charAt(j);
} else {
if (!temp.equals("")) {
set.add(temp);
}
temp = "";
}
if (j == str[i].length() - 1 && !temp.equals("")) {
set.add(temp);
}
}
}
for (String ele : set) {
list.add(Integer.parseInt(ele));
}
return list.stream().mapToInt(i -> i.intValue()).toArray();
}
}