leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE |

1614.cpp (292B)


1 class Solution { 2 public: 3 int maxDepth(const string &s) const { 4 int res = 0, cnt = 0; 5 6 for (const char c : s) { 7 if (c == '(') 8 cnt++; 9 else if (c == ')') 10 res = max(res, cnt--); 11 } 12 13 return res; 14 } 15 };