Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int balancedStringSplit(string s) {
- int countR = 0;
- int countL = 0;
- int countTot = 0;
- for (int i = 0; i <= s.length(); i++)
- {
- if (s[i] == 'R')
- {
- countR++;
- }
- else if (s[i] == 'L')
- {
- countL++;
- }
- if ((countR >= 1 && (countR == countL)))
- {
- countL = 0;
- countR = 0;
- countTot++;
- }
- }
- return countTot;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement