1
class Solution {
2
public:
3
int balancedStringSplit(string s) {
4
int left = 0;
5
int right = 0;
6
int cnt = 0;
7

8
for (int i = 0; i < s.size(); i++) {
9
if (s[i] == 'L') {
10
left++;
11
}
12
if (s[i] == 'R') {
13
right++;
14
}
15

16
if (left - right == 0) {
17
cnt++;
18
}
19
}
20

21
return cnt;
22
}
23
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0