2026年技术岗位面试题及答案招聘工程师参考手册.docxVIP

  • 4
  • 0
  • 约6.04千字
  • 约 20页
  • 2026-02-07 发布于福建
  • 举报

2026年技术岗位面试题及答案招聘工程师参考手册.docx

第PAGE页共NUMPAGES页

2026年技术岗位面试题及答案:招聘工程师参考手册

一、编程语言与数据结构(10题,每题10分)

(针对互联网、大数据、人工智能行业,侧重Java/Python/Go/JavaScript)

1.题目:

请用Python实现一个LRU(最近最少使用)缓存,要求时间复杂度为O(1)的get和put操作。

答案:

python

fromcollectionsimportOrderedDict

classLRUCache:

def__init__(self,capacity:int):

self.cache=OrderedDict()

self.capacity=capacity

defget(self,key:int)-int:

ifkeynotinself.cache:

return-1

self.cache.move_to_end(key)

returnself.cache[key]

defput(self,key:int,value:int)-None:

ifkeyinself.cache:

self.cache.move_to_end(key)

self.cache[key]=value

iflen(self.cache)self.capacity:

se

文档评论(0)

1亿VIP精品文档

相关文档