Codility - Missing Integer

RESULT

import java.util.*;

class Solution {
    public int solution(int[] A) {
        boolean[] array = new boolean[A.length + 1];
        for (int a : A) {
            if (a > 0 && a <= A.length) {
                array[a] = true;
            }
        }
        
        for (int i = 1; i < array.length; i++) {
            if (!array[i]) {
                return i;
            }
        }
        
        return array.length;
    }
}