leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1221.cpp (372B)


0 class Solution {
1 public:
2 int balancedStringSplit(const string &s) const {
3 const int n = size(s);
4 int res = 0;
6 for (int i = 0; i < n; i++) {
7 int count = s[i] == 'L' ? 1 : -1;
8 while (count != 0) {
9 count += s[++i] == 'L' ? 1 : -1;
10 }
11 res++;
12 }
14 return res;
15 }
16 };