Description

Design a browser history system supporting visit(url), back(steps), and forward(steps). Start with homepage.

Examples

Input:homepage="leetcode.com", visit("google.com"), back(1)
Output:"leetcode.com"
Explanation:

Go back to homepage.

Input:homepage="a", visit("a"), back(1)
Output:"leetcode.com"
Explanation:

Edge case with a single character.

Input:homepage="github.com", visit("stackoverflow.com"), visit("reddit.com"), back(2), forward(1)
Output:stackoverflow.com
Explanation:

Start at github.com, visit stackoverflow.com and reddit.com. Back 2 steps goes to github.com, then forward 1 step goes to stackoverflow.com.

Constraints

  • 1 ≤ homepage.length ≤ 20
  • 1 ≤ url.length ≤ 20

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!