Wayfair Interview Question

Given a string of brackets, return if string is valid or not. String is valid if all opening brackets have matching closing brackets. Example: {[()]} = valid {()[]} = valid {[} = invalid

Interview Answer

Anonymous

Aug 26, 2016

Push the open bracket onto the stack when you see it, and pop the open bracket off the stack when you see a closing bracket