Stack • Easy

Valid Parentheses

Given a string `s` containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

The Challenge

Given a string `s` containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

Difficulty Easy
Topic Stack

Pro-tip: Use a stack. Push opening brackets and pop/compare when you see a closing bracket.

Solution.swift Tests.swift
Output
Ready to run.