Baseline Stack and Queues · Learning O(n) · O(n)
A network appliance parses configuration lines made only of round, square, and curly brackets. A line is accepted only if every opening symbol is sealed by its exact matching partner, seals occur in the correct nesting order, and no closer appears without a pending opener. Write the audit routine that accepts or rejects each line.
Input: A string s containing only the characters '(', ')', '{', '}', '[' and ']'.
Output: Return true if the bracket sequence is valid, false otherwise.
1 <= s.length <= 10^4s consists of bracket characters onlyInput: {"s":"()[]{}"}
Output: true
Each bracket pair is well-formed and the three pairs sit side by side.
Input: {"s":"(]"}
Output: false
A round opener cannot be sealed by a square closer.