Input string and the number of R L has the same
title and the balancing requirements are not required string, when each character string balancing the requirements of an application or a dual stack pointer traversal
class Solution {
public:
int balancedStringSplit(string s) {
int ans = 0, cnt = 0;
for(int i = 0; i < s.size(); ++i)
{
if(s[i] == 'L') ++cnt;
else --cnt;
if(!cnt) ++ans;
}
return ans ? ans : 1;
}
};