← back to unit
Medium
# stacks medium
Bottom of the Pile
The FIRST pancake — the legendary burnt one — sits at the bottom. Reach it without wrecking the pile! 🥞
You get the pile bottom to top (at least one item). Using only push and pop (no peeking inside!), move things to a helper pile to reach the bottom item. Print the bottom item, then the restored pile, comma-separated, on two lines.
Example:
Input: pile = ["burnt", "golden", "fluffy"]
Output:
burnt
burnt,golden,fluffy
Popping fluffy and golden onto a helper pile reaches burnt at the bottom. Pouring the helper back on top restores the original order.
💡 need a hint?
stk-bottom-of-pile.py🔒 given lines are locked — write your code in between
loading...