naive sol
recursive with indicator of the right neighbor
sol of q116