Editorial solution in java FAILS


#1

The editorial solution in java doesn’t work for the below case.

4 7 5 3 1
3 6 4 2

Can someone please check that?