Given a string s containing just the characters '(', ')', '[', ']', '{' and '}', determine if the input string is valid. An input string is valid if every open bracket is closed by the same type of bracket and in the correct order.
s = "()"trues = "()[]{}"trues = "(]"falses = "{[]}"true()[]{}( [ { → push onto stackfalse (unmatched closer)falsestack.isEmpty() — true iff all opened brackets were closedStack mirrors nesting: the most recently opened bracket must be the first to close — LIFO is exactly the nesting order of brackets. Every time we hit a closer, the only valid matching opener is the one on top of the stack.