滴滴第二题 。。。为何只能 ac 80% 求指教!!!
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<Integer>();
TreeSet<Integer> set = new TreeSet<Integer>();
Scanner scanner= new Scanner(System.in);
String str = scanner.nextLine();
int k = scanner.nextInt();
String[] s = str.split(" ");
for(int i = 0; i < s.length; i++) {
set.add(Integer.parseInt(s[i]));
}
if(k >= set.size() || k <= 0) {
System.out.println(-1);
}
for(Integer i : set) {
list.add(i);
}
System.out.println(list.get(list.size()-k));
}
}