leetle

Daily challenge for 2026-08-01

578. Browser History Steps

You are given a list of actions representing a user's browser history. The actions can be 'visit' (visit a new page), 'back' (go back one page), or 'forward' (go forward one page). You start on a blank page. Return the total number of pages currently in the 'back' history (i.e., the size of the history stack behind the current page). If you try to go back when there is no history, nothing happens. If you try to go forward when there is no forward history, nothing happens. Visiting a new page clears all forward history.

Example:
Input: actions = ["visit", "visit", "back", "visit"]
Output: 2
Explanation: Start empty. Visit -> 1 back page. Visit -> 2 back pages. Back -> 1 back page. Visit -> 2 back pages (forward history cleared).

Run this challenge interactively in Python or JavaScript when the app loads.