Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Input: s = "()"
Output: true
Input: s = "()[]{}"
Output: true
Input: s = "(]"
Output: false
Input: s = "([])"
Output: true
Input: s = "([)]"
Output: false
s consists of parentheses only '()[]{}'.The problem of validating parentheses can be efficiently solved using a stack data structure as it is ideal for problems involving matched pairs and nested structures. The idea here is to iterate through the characters of the string and use the stack to keep track of opening parentheses. When we encounter a closing parenthesis, we check if it matches the top of the stack. If it does, we can pop the stack; otherwise, the string is invalid.