Workspace

Problem workspace

3 day streakD
Back to the problem sheet
PRACTICE · STACKS

Valid Parentheses

Easy42.3% acceptanceSample problem

The challenge

Given a string containing brackets, decide whether every opening bracket has a matching closing bracket of the same type, in the correct order.

Example

Input s = "({[]})"

Output true

Every pair closes in the reverse order it was opened.

Before you begin

  • Read through the example and consider edge cases.
  • Write down a simple solution before optimizing.
  • Describe the time and space complexity of your approach.

A space to understand the problem. Use your favorite editor to write and run your solution.

A good place to start

Explore a pattern

A little guidance

Start with a pattern, read through a problem, and mark it solved when the idea clicks. Save anything you want to revisit.

This preview uses sample content. Your bookmarks and solved checkmarks stay in this browser.

Explore the roadmap