fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s = "((()(())))";
  7.  
  8. int level =0;
  9. int l=0;
  10. int max_level =0;
  11. while(l<s.size())
  12. {
  13. if(s[l]=='(')
  14. {
  15. level++;
  16. }
  17. else
  18. {
  19. level--;
  20. }
  21. max_level = max(level,max_level);
  22. l++;
  23. }
  24. cout<<"levle is :" <<max_level;
  25.  
  26. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
levle is :4