C++ Browser History using std::list (100% faster and 100% memory efficient)
\nstatic const auto ____ = [](){\n    ios_base::sync_with_stdio(false);\n    cin.tie(nullptr), cout.tie(nullptr);\n    return 0;\n}();\n\nclass BrowserHistory {
```\nstatic const auto ____ = [](){\n    ios_base::sync_with_stdio(false);\n    cin.tie(nullptr), cout.tie(nullptr);\n    return 0;\n}();\n\nclass BrowserHistory {\n    list<string> history;\n    list<string>::iterator tab;\n    \npublic:\n    BrowserHistory(string homepage) {\n        history.clear();\n        tab = history.insert(history.end(), homepage);\n    }\n    \n    void visit(string url) {\n        if(!history.empty() && history.back() == url)   return; \n        else if(!history.empty() && tab != history.end())   history.erase(++tab, history.end());\n\n        tab = history.insert(history.end(), url);\n    }\n    \n    string back(int steps) {\n        if(*tab == history.front())    return history.front();\n        while(steps--) {\n            tab--;\n            if(*tab == history.front())  return history.front();\n        }\n        return *tab;\n    }\n    \n    string forward(int steps) {\n        if(*tab == history.back())    return history.back();\n        while(steps--) {\n            tab++;\n            if(*tab == history.back())    return history.back();\n        }\n        return *tab;\n    }\n};\n\n```
[]