Problem 777 · Medium

Swap Adjacent in LR String

Two pointers match the L and R letters in order while checking they only move in their legal direction.

Open the interactive visualisation