Java | ArrayList | Clean code
Code\n\nclass BrowserHistory {\n  private List<String> list;\n  private int currIdx;\n  private int lastIdx;\n\n  public BrowserHistory(String homepage) {\n    
# Code\n```\nclass BrowserHistory {\n  private List<String> list;\n  private int currIdx;\n  private int lastIdx;\n\n  public BrowserHistory(String homepage) {\n    list = new ArrayList<>(Arrays.asList(homepage));\n    currIdx = lastIdx = 0;\n  }\n  \n  public void visit(String url) {\n    currIdx++;\n    lastIdx = currIdx;\n\n    if (currIdx < list.size())\n      list.set(currIdx, url);\n    else\n      list.add(url);\n  }\n  \n  public String back(int steps) {\n    currIdx = Math.max(0, currIdx - steps);\n    return list.get(currIdx);\n  }\n  \n  public String forward(int steps) {\n    currIdx = Math.min(currIdx + steps, lastIdx);\n    return list.get(currIdx);\n  }\n}\n```
['Java']