Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
kth smallest element
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.io.*; import java.util.*; import java.lang.*; class Rextester { private static List<Integer> li = new ArrayList<Integer>(); public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0){ int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; StringTokenizer st = new StringTokenizer(br.readLine()); for(int i=0;i<n;i++){ //if(st.hasMoreToken()) arr[i] = Integer.parseInt(st.nextToken()); } int k = Integer.parseInt(br.readLine()); Arrays.sort(arr); li.add(arr[k-1]); } for(int i=0;i<li.size();i++) System.out.println(li.get(i)); } }
run
|
edit
|
history
|
help
0
Simple String Reverse
epeenconverter
3.F
Greedy algo Activity program
innerclssss
program
Implement Queue with Limited Size of Arrays
quickSort_LinkedList
Compare three ways to clear a String in java
Validate BST