Why answer different between local machine and OJ?

• struct Node
{
int nKey;
int nValue;
int pre;
int next;
Node()
{
pre = -1;
next = -1;
}
};

Node l[10000];
int nTop = 0;
int nTail = -1;

class LRUCache{
public:
LRUCache(int capacity) {
maxsize = capacity;
use.clear();
}

``````int get(int key) {
return GetValue(key);
}

void set(int key, int value) {
if (use.find(key) == use.end() && use.size() >= maxsize )
{
RemoveLast();
}
RefresKey(key,value);
}
int GetValue(int key)
{
if (use.find(key) != use.end())
{
int nIndex = use[key];
int nValue = l[nIndex].nValue;
RefresKey(nIndex,nValue);
return nValue;
}
else
{
return -1;
}
}

void RemoveLast()
{
if (use.find(key)!=use.end())
{
use.erase(use.find(key));
}
}

void RefresKey(int key,int value)
{
if(use.find(key)!=use.end())
{
int nIndex = use[key];
int npre = l[nIndex].pre;
int nnext = l[nIndex].next;

l[nIndex].nValue = value;
l[nIndex].nKey = key;

if (nIndex == nTail)
{
return;
}
{
}

if (npre != -1)
{
l[npre].next = nnext;
}
if (nnext != -1)
{
l[nnext].pre = npre;
}

l[nTail].next = nIndex;
l[nIndex].pre = nTail;
nTail = nIndex;
}
else
{
Node &newnode = l[nTop++];
newnode.pre = -1;
newnode.next = -1;
newnode.nValue = value;
newnode.nKey = key;
{
}
if (nTail == -1 )
{
nTail = nTop - 1;
}
else
{
l[nTail].next = nTop-1;
newnode.pre = nTail;
nTail = nTop - 1;
}
use[key] = nTop - 1;
}
return ;
}

map<int,int> use;
int maxsize;
``````

};

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.