What's wrong with my idea? The OJ says limited time exceed!!!

I don't know which part of my answer is slow

```
class LRUCache{
public:
int size;
unordered_map<int,int> visited;
list<int> least_used; //front is the most recently used, end is the least recently used.
LRUCache(int capacity) {
size = capacity;
}
int get(int key) {
int ret = -1;
if(visited.find(key) != visited.end()){
ret = visited[key];
least_used.remove(key);
least_used.push_front(key);
}
return ret;
}
void set(int key, int value) {
if(visited.find(key) != visited.end()){
least_used.remove(key);
least_used.push_front(key);
}else{
if(least_used.size() < size){
least_used.push_front(key);
visited[key] = value;
}else{
int remove_key = least_used.back();
visited.erase(remove_key);
least_used.pop_back();
least_used.push_front(key);
visited[key] = value;
}
}
}
```

};