2026年网易游戏开发工程师面试题库.docxVIP

  • 1
  • 0
  • 约8.42千字
  • 约 24页
  • 2026-11-05 发布于福建
  • 举报

第PAGE页共NUMPAGES页

2026年网易游戏开发工程师面试题库

一、编程基础(共5题,每题10分)

目标:考察候选人对C++/Java等游戏开发核心语言的理解及编程能力。

1.题目:

实现一个LRU(LeastRecentlyUsed)缓存,支持get和put操作。缓存容量为固定值。要求用C++实现,并说明时间复杂度和空间复杂度。

答案:

cpp

includeunordered_map

includelist

classLRUCache{

private:

intcapacity;

std::unordered_mapint,std::pairint,std::listint::iteratorcache;

std::listintlruList;

public:

LRUCache(intcapacity_):capacity(capacity_){}

intget(intkey){

autoit=cache.find(key);

if(it==cache.end())return-1;

lruList.erase(it-second.second);

lruList.push_front(key);

returnit-second.first;

}

voidput(intkey,intvalu

文档评论(0)

1亿VIP精品文档

相关文档