TeslaOA #3
Maximum Number of Workers with Equal Left and Right Shoes
估计简单可在线判题
Partition all the shoes into contiguous, non-overlapping segments, each with the same number of L and R, and find the maximum number of segments. Every shoe must belong to a segment.
输入格式
One line containing a string of L/R of length 2 to 100000; the numbers of L and R are guaranteed to be equal.
输出格式
Output the maximum number of segments.
样例 1
输入:
LRLR
输出:
2
样例 2
输入:
LLRR
输出:
1
样例 3
输入:
RLLRRL
输出:
3
样例说明
LRLR splits into LR and LR; LLRR can only form one segment; RLLRRL splits into three segments: RL, LR, RL.