Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Valid Parentheses

Python data engineering interview problem. Difficulty: beginner. Pattern: Stacks. About 10 minutes. Free to practice.

Check whether brackets are correctly matched and nested. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement valid_parentheses(s: str) -> bool for (), [], {}. , "(]" → False.

Constraints

  • Only ()[]{} characters appear.

Examples

Input: valid_parentheses('()[]{}') Output: True Each close matches the latest open.

Topics: lakebench, python, stack, brackets.

More Python interview questions · All interview problems · Learn data engineering

beginner

Valid Parentheses

Interview-style drill: Check whether brackets are correctly matched and nested.

Implement `valid_parentheses(s: str) -> bool` for (), [], {}. Example: `"()[]{}"` → `True`, `"(]"` → `False`. Keep the harness.