Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <string>
- using namespace std;
- string a;
- int count , maxCount = 0, minCount = 0;
- int main() {
- getline(cin, a);
- for (int i = 0 ; i < a.length() ; i++) {
- if (a[i] == 'R') count++;
- if (a[i] == 'L') count--;
- if (count > maxCount) maxCount = count;
- if (count < minCount) minCount = count;
- }
- cout << maxCount - minCount + 1;
- return 0;
- }
Add Comment
Please, Sign In to add comment