Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int balanced_string_split(const char * str)
- {
- int rs, ls, splits = 0;
- const char * cptr;
- while (rs = ls = 0, cptr = str, *str)
- {
- do
- {
- if ('R' == *cptr)
- rs++;
- else
- ls++;
- if (rs == ls)
- splits++;
- else if (2 == rs - ls || -2 == rs - ls)
- break;
- } while (*cptr++);
- str++;
- }
- return splits;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement