刷题记录
文章平均质量分 58
力扣等刷题记录
骜蛟
砥砺前行
展开
-
力扣146|LRU缓存淘汰算法
不论是插入还是更新,id为key的缓存页都被访问了一次,需要将它的优先级提高。LRU全名Last Recently Used,即当缓存空间满时,优先淘汰最不常使用(访问)的缓存。2、 put(key, val) 将id为key的缓存加入缓存空间,要求O(1)时间复杂度。在get一个缓存时,访问了一遍id为key的缓存,需要提高它的优先级。3、get(key) 得到id为key的缓存,要求O(1)时间复杂度。put要做的事情:判断key在不在链表中,相应的修改/插入操作行为。哈希链表要实现哪些API?原创 2023-09-29 10:54:47 · 175 阅读 · 0 评论 -
PAT 1025|PAT Ranking
题目链接:点击进入解析:题目不难,两次排序即可。有趣的点是这个 The testees with the same score must have the same rank, and the output must be sorted in nondecreasing order of their registration numbers. 同样成绩的人要有同样的排名。 for(int l=1;l<sum;l++){ if(stu[l].score != stu[l.原创 2021-10-04 20:49:12 · 77 阅读 · 0 评论