deno.land / x / masx200_leetcode_test@10.6.5 / 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;}
Version Info