Your question is Validate Nested Brackets. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Cox Automotive's Dealer.com services exchange payloads that may contain nested grouping markers. Implement a method that determines whether a string of brackets is properly nested and closed.
A string is valid when every opening bracket has the correct closing bracket, brackets close in last-in, first-out order, and no closing bracket appears without a matching opener. The supported bracket pairs are (), [], and {}. An empty string is valid.
Implement is_valid_brackets(s), where s is a string containing only the six bracket characters. Return True if the brackets are properly nested, otherwise return False.
def is_valid_brackets(s):