dsa · medium
Design Browser History
GreyOrangeStackDesign
BrowserHistory(homepage), visit(url) (clears forward), back(steps), forward(steps) return the current url.
Fill in the BrowserHistory class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.
**Example**
`` BrowserHistory("dojo.shizuha.com") → null visit("pulse.shizuha.com") → null visit("hive.shizuha.com") → null visit("cortex.shizuha.com") → null back(1) → "hive.shizuha.com" back(1) → "pulse.shizuha.com" forward(1) → "hive.shizuha.com" visit("wiki.shizuha.com") → null forward(2) → "wiki.shizuha.com" back(2) → "pulse.shizuha.com" back(7) → "dojo.shizuha.com" ``
Constraints
Calls <= 500
Examples
Example 1
Input: ["BrowserHistory","visit","visit","visit","back","back","forward","visit","forward","back","back"] [["dojo.shizuha.com"],["pulse.shizuha.com"],["hive.shizuha.com"],["cortex.shizuha.com"],[1],[1],[1],["wiki.shizuha.com"],[2],[2],[7]] Expected: [null,null,null,null,"hive.shizuha.com","pulse.shizuha.com","hive.shizuha.com",null,"wiki.shizuha.com","pulse.shizuha.com","dojo.shizuha.com"]