1614. Maximum Nesting Depth of the Parentheses Posted on 2021-02-15 In LeetCode Disqus: Symbols count in article: 208 Reading time ≈ 1 mins. 扫描线 O(n) time O(1) space 1234567891011class Solution {public: int maxDepth(string s) { int res = 0, cnt = 0; for (char c : s) { cnt += c == ')' ? -1 : (c == '('); res = max(res, cnt); } return res; }};