Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. class Solution {
  2. public:
  3. int balancedStringSplit(string s) {
  4. int countR = 0;
  5. int countL = 0;
  6. int countTot = 0;
  7. for (int i = 0; i <= s.length(); i++)
  8. {
  9. if (s[i] == 'R')
  10. {
  11. countR++;
  12. }
  13. else if (s[i] == 'L')
  14. {
  15. countL++;
  16. }
  17. if ((countR >= 1 && (countR == countL)))
  18. {
  19. countL = 0;
  20. countR = 0;
  21. countTot++;
  22. }
  23. }
  24. return countTot;
  25.  
  26. }
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement