data-structures · beginner · ~15 min

Maximum nesting depth

Track a stack depth's high-water mark.

Challenge

Implement int max_depth(const char *s) returning the deepest level of nested round parentheses. Assume the parentheses are balanced.

Starter code

int max_depth(const char *s) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.