Java code(easy)


#1

public class Solution {
public int solve(ArrayList A) {
if (A.size() == 0) {
return -1;
}
Collections.sort(A);
int n = A.size() - 1;

    for (int i = n; i >= 0; i--) {
        if (A.get(i) == n - i) {
            if (n - i == 0) {
                return 1;
            } else if (n - i > 0  && (A.get(i) < A.get(i + 1))) {
                return 1;
            }
       }
    }
   
    return -1;
}

}