Posted on

Description

Submission

class Solution {
public:
    int maxDepth(string s) {
        int ret = 0;
        int cur = 0;

        for(auto ch: s) {
            if(ch == '(') ++cur;
            else if(ch == ')') --cur;

            ret = max(cur, ret);
        }

        return ret;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *