Dsa
Stack
Easy
Browser Backward Navigation
You are building a simple browser that supports backward navigation. For each valid URL visited, the user can go back one step to the previous URL. Write a program to manage the browser history and output the current URL after a series of back operations.
Input Format:
- The first line contains an integer n (1 <= n <= 1000), the number of URLs.
- The next n lines each contain a URL visited.
- The last line contains an integer m (1 <= m <= 1000), the number of back operations.
Output Format:
- Print the final current URL after performing all back operations. If there are no URLs to go back to, print 'No more URLs'.
Example:
Input:
5
example.com
example.org
example.net
example.edu
example.io
3
1
1
1
Output:
example.org
Key concepts
stacknavigationhistory
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