Microsoft Interview Question

validate a sequence of parens and brackets, subsequence cannot be closed before opened ]() or (]) are invalid