x/masx200_leetcode_test/maximum-nesting-depth-of-the-parentheses/index.ts
1234567891011121314export default function maxDepth(s: string): number { let ans = 0; let depth = 0; for (const char of s) { if (char === "(") { depth++; ans = Math.max(depth, ans); } else if (char === ")") { depth--; } } return ans;}