Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Web Browser History - SET
#include<bits/stdc++.h> using namespace std; map<string, int> db; struct myComp{ bool operator()(string a, string b) const { return db[a] > db[b]; } }; set<string, myComp> history; int timeStamp; // ================================================================ void init() { history.clear(); db.clear(); timeStamp = 0; } void access(string link) { if(db.find(link)==db.end()) return; history.erase(link); db[link] = timeStamp; timeStamp += 1; history.insert(link); //printList(); } void visit(string link) { if(db.find(link)!=db.end()) { //cout << "VISIT-ACCESS\n"; access(link); return; } db[link] = timeStamp; timeStamp += 1; history.insert(link); //printList(); } void deleteLink(string link) { if(db.find(link)==db.end()) return; history.erase(link); db.erase(link); //printList(); } 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
Ploshtina na pravoagolnik
variadic pointer to function template
sin_approximation
backtracking
¡Arriba, Papalotes, Arriba! v2
Two pointer - MUST DO
ArrAdSubMul
cppPyGuessTheNum2
queue
Ballin primality test