Guest User

Untitled

a guest
Jul 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. public static int suurin(int k, int[] luvut) {
  2. TreeSet<Integer> ts = new TreeSet();
  3.  
  4. for(int i = 0; i < luvut.length; i++) {
  5. if(ts.size() == k && ts.first()<=luvut[i]) {
  6. ts.pollFirst();
  7. ts.add(luvut[i]);
  8. } else if(ts.size() < k) {
  9. ts.add(luvut[i]);
  10. }
  11. }
  12. return ts.first();
  13. }
Add Comment
Please, Sign In to add comment