# stacks advanced

Well-Nested Recipe?

Kitchen law: whatever you begin must end — and you must finish the CURRENT task before ending an earlier one. 👩‍🍳

You get commands like begin:bake, end:bake. Print well nested if every end matches the most recent unfinished begin and nothing is left unfinished, otherwise tangled.

Example:

Input: commands = ["begin:bake", "begin:mix", "end:mix", "end:bake"] Output: well nested

mix (the most recently begun task) ends first, then bake — each end matches the most recent unfinished begin.

💡 need a hint?

stk-well-nested-recipe.py🔒 given lines are locked — write your code in between
loading...