Home
Connect Wallet
Lixv
@39427696

手写一个LRU算法

编程 LRU Go Go语言
2023-01-19 10:44 Words count: 3576
你是否想知道,手机上的应用是怎样按照使用前后顺序来排序的,并且当手机内存不够时是如何淘汰(关闭)应用的?这些都离不开LRU算法 这个问题也是leetcode上的经典问题 https://leetcode.com/problems/lru-cache 题目:...

你是否想知道,手机上的应用是怎样按照使用前后顺序来排序的,并且当手机内存不够时是如何淘汰(关闭)应用的?这些都离不开LRU算法

这个问题也是leetcode上的经典问题

https://leetcode.com/problems/lru-cache

题目:

请你设计并实现一个满足 LRU (最近最少使用) 缓存 约束的数据结构。实现 LRUCache 类:

LRUCache(int capacity) 以 正整数作为容量 capacity 初始化 LRU 缓存 int get(int key) 如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。 void put(int key, int value) 如果关键字 key 已经存在,则变更其数据值 value ;如果不存在,则向缓存中插入该组 key-value 。如果插入操作导致关键字数量超过 capacity ,则应该 逐出最久未使用的关键字。

90.0 % More to go
Pay 0.00250 XIN to continue reading
≈$0.2095
Pay to Read
and receive early reader revenue (Rules)
This post is a virtural product selling on Quill, IT WILL NOT REFUND once paid. Please pay with caution.
Already paid? Try to Login
0 0
1 times bought
•
0 times reward
Comments 0
Lixv
@39427696
19 Posts 33 Subscribers 12 Subscribing
Joined at September 08, 2021
我本深渊
Subscribe
Related Posts
Defi乐高之借贷协议(2)--MarginFi 隐身3个月通关编程实战项目,升级进取型思维分享。 macOS系统多开Google Chrome浏览器 从小白到科学家(二)之脱胎换骨 Invoke the closed source contract tutorial with MetaMask
© 2026 Quill
Rules Stats Help Github
手写一个LRU算法
Pay to Read