help in a codeforce question.

Did u consider the edge cases like when r-l<=2,also changing at l and r

This is my ac code :

see if u understand it.

If u dont,tell me.I’ll explain when i get time