SHARE
TWEET

Untitled

a guest Mar 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. public class Solution {
  4.     private List<Integer> list = new ArrayList<>();
  5.  
  6.     void addL(Integer a){
  7.  
  8.  
  9.         list.add(a);
  10.  
  11.     }
  12.     int solution()
  13.     {
  14.  
  15.         Collections.sort(list);
  16.         int min = list.get(0);
  17.  
  18.             for(int i=0;i<list.size()-1;i++) {
  19.                 if (list.get(i+1) - list.get(i) >=2 )
  20.                 {
  21.                     min = list.get(i)+1;
  22.  
  23.                     break;
  24.                 }
  25.  
  26.                    if( list.get(list.size()-1) < 1)
  27.                    {
  28.                     min = 1;
  29.                 }
  30.             }
  31.  
  32.         System.out.println(list);
  33.         System.out.println(min);
  34.  
  35.         return 0;
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top