← 返回 tesla 的题目列表Maximize Number of Intervals with Shoes
类型:online_judge
Given a string S consisting of letters 'L' and 'R' representing left and right shoes, find the maximum number of intervals such that each interval contains an equal number of 'L's and 'R's. Implement the function solution(s: str) -> int.
Input:
A string S with a maximum length of 100,000, consisting only of characters 'L' and 'R'.
Output:
An integer representing the maximum number of intervals that can be split.
Examples:
Input: "RLRRLLRLRL"
Output: 4
Input: "RLLLLRRRLR"
Output: 3
Input: "LLLLRRRR"
Output: 1
Example
Input
RLRRLLRLRL