Advertisement
Guest User

Untitled

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