




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Loop from left to right maintaining a balance variable when it gets an L increase it by one otherwise decrease it by one.
Whenever the balance variable reaches zero then we increase the answer by one.