求第k大
寻找第K大
http://www.nowcoder.com/questionTerminal/e016ad9b7f0b45048c58a9f27ba618bf
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
String str = sc.nextLine();
String replace = str.replace("[", "").replace("]", "");
String[] split = replace.split(",");
Integer n = null;
Integer k = null;
Set<integer> set = new HashSet<>();
for (int i = 0; i < split.length; i++) {
if (i == (split.length - 1)) {
k = Integer.parseInt(split[i]);
}
if (i == (split.length - 2)) {
n = Integer.parseInt(split[i]);
}
set.add(Integer.parseInt(split[i]));
}
List<integer> collect = set.stream().sorted(Comparator.comparing(Integer::intValue).reversed()).collect(Collectors.toList());
System.out.println(collect.get(k - 1));
}</integer></integer>
}
}