Not pasing all test cases


#1

public ArrayList solve(ArrayList A) {
ArrayList res= new ArrayList();
int size= A.size();
res.add(A.get(size-1));
int max=A.get(size-1);
for(int i= size-2; i > 0; i–){
if(A.get(i) > max){

            res.add(A.get(i));
            max= A.get(i);
        }
    }
    return res;
}

#2

Shouldn’t it be i >= 0 ? Let me know if this helps