Question: please right in python Write a function: def solution (S) that, given a string S of letters L and R, denoting the types of shoes

please right in python
Write a function: def solution (S) that, given a string S of letters "L" and "R", denoting the types of shoes in line (left or right), returns the maximum number of intervals such that each interval contains an equal number of left and right shoes. For example, given S "RLRRLLRLRRLL", the function should return 4, because S can be split into intervals: "RL, "RRLL", "RL" and "RRLL". Note that the intervals do not have to be of the same size
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
