Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class solution {
  2.    
  3.     public int solution(int[] A) {
  4.         ArrayList <Integer> listToSort = new ArrayList <Integer>();
  5.         int lowestValue = 0;
  6.         for (int i = 0; i<A.length-1; i++){
  7.             if (A[i]>0){
  8.                 listToSort.add(A[i]);
  9.             }
  10.         }
  11.         Collections.sort(listToSort);
  12.         for (int i = 0; i<listToSort.size()-1; i++){
  13.             if (listToSort.get(i) > i+1){
  14.                 lowestValue = listToSort.get(i);
  15.             }
  16.         }
  17.         return lowestValue;
  18.     }
  19.    
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement