Frog Jump(Codility) impl in java