Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Web Browser History - LIST
#include<stdio.h> #include<bits/stdc++.h> using namespace std; list<string> history; map<string, int> db; // ================================================================ void init(){ history.clear(); db.clear(); } void access(string link){ if(db.find(link)==db.end()) return; history.remove(link); history.push_front(link); } void visit(string link){ if(db.find(link)!=db.end()) { access(link); return; } history.push_front(link); db[link] = 1; } void deleteLink(string link){ if(db.find(link)==db.end()) return; history.remove(link); db.erase(link); } vector<string> last5(){ vector<string> ans; for(auto it= history.begin();it!=history.end();it++) { ans.push_back(*it); if(ans.size() == 5) break; } return ans; }
run
|
edit
|
history
|
help
0
Laborator 2 SD
Test 4(2017)
ShoppingList
good triplet
ignat
Easy String Reverse Example
Sangharsh.vhawale
Boost phoenix. e.g 3 phoenix: functor
e-olymp.com---problem1590---Birthday 2
stack and queue