Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string s;
- cin >> s;
- int c_r = 0, c_t = 0;
- for (int i = 0; i < s.size(); i++)
- {
- if (s[i] == '(')
- {
- c_r++;
- }
- else if (s[i] == ')' && c_r != 0)
- {
- c_t++;
- c_r--;
- }
- }
- cout << c_t * 2;
Advertisement
Add Comment
Please, Sign In to add comment