#C4444. Valid Parentheses Checker
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:
- Every opening bracket has a corresponding closing bracket of the same type.
- 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 , where 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>