Question bank › Queue
Dsa Queue Medium

Browser History Navigation

You are building a simple browser history feature. The user can navigate back and forth through their browsing history. Each action is recorded as either 'visit <url>', 'back', or 'forward'. Implement the browser history functionality using a queue that maintains the current position in the history. If a user tries to go back but there are no previous pages, return 'No previous page'. If a user tries to go forward but there are no forward pages, return 'No forward page'. Your program will receive a number of actions followed by those actions. Output the current URL after processing each action. Example Input: 5 visit google.com visit facebook.com back forward back Example Output: google.com facebook.com google.com No forward page facebook.com

Key concepts

queuehistorybrowser

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.