Dsa
Stack
Warm-up
The Breadcrumb Navigator
A hiker is recording their path through forest clearings. Every time they enter a clearing, they record its name. If they decide to go back to the previous clearing, they record the word 'BACK'. Given a sequence of recordings, determine the hiker's current location. If they go 'BACK' from the first clearing, they are 'LOST'. If they end up with no clearings left, they are 'HOME'.
Example:
Input: Meadow Forest Cave BACK River
Output: River
Key concepts
stackpath processing
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now