I dont understand whats wrong in this


#1

`map<int,int> m;
deque q;
int c;
LRUCache::LRUCache(int capacity) {
c=capacity;
q.clear();
m.clear();
}

int LRUCache::get(int key) {
if(m.find(key)!=m.end())
{
return key;
}
else
{
return -1;
}
}

void LRUCache::set(int key, int value) {
int id;
if(q.size()>=c)
{
if(m.find(key)!=m.end())
{
for(int i = 0; i < q.size(); i++)
{
if(q[i] == key)
{
id = i;
break;
}
}
q.erase(q.begin()+id);
m.erase(key);
}
else
{
m.erase(q.front());
q.pop_front();
}
q.push_back(key);
m[key]=value;

}
else
{
    if(m.find(key)==m.end())
    {
        q.push_back(key);
        m[key]=value;
    }
    
}
//m[key]=value;

}`