#C4444. Valid Parentheses Checker

    ID: 47983 Type: Default 1000ms 256MiB

Valid Parentheses Checker

Valid Parentheses Checker

You are given a string containing only the characters '(', ')', '{', '}', '[' and ']'. The task is to determine whether the input string is a valid sequence of parentheses. A string is considered valid if:

  1. Every opening bracket has a corresponding closing bracket of the same type.
  2. Opening brackets must be closed in the correct order.

For example, the string ()[]{} is valid, but ([)] is not. The solution should follow a stack-based approach with a time complexity of O(n)O(n), where nn is the length of the string.

This problem is often encountered in coding competitions and interviews.

inputFormat

The input consists of a single line containing a string of parentheses characters.

outputFormat

Output a single line: 'True' if the parentheses string is valid, or 'False' otherwise.## sample

()
True

</p>