Zepruv › Coding problems

Valid Parentheses

Easy · String, Stack

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

Example 1

Input: s = "()"
Output: true

Example 2

Input: s = "()[]{}"
Output: true

Example 3

Input: s = "(]"
Output: false

Example 4

Input: s = "([])"
Output: true

Example 5

Input: s = "([)]"
Output: false

Constraints

Starter code (python)

class Solution(object):
    def isValid(self, s):
        """
        :type s: str
        :rtype: bool
        """
        

Related problems

Previous: Remove Nth Node From End of List · Next: Merge Two Sorted Lists · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.