data-structures · intermediate · ~15 min
Use a stack to match nested delimiters.
Implement int paren_balanced(const char *s) returning 1 if every '(', '[', '{' is correctly matched and nested with its closer, else 0. Non-bracket characters are ignored.
int paren_balanced(const char *s) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.