
leetcode
文章平均质量分 84
natures66
这个作者很懒,什么都没留下…
展开
-
leetcode题目-LRU缓存机制
题目: 运用你所掌握的数据结构,设计和实现一个LRU (最近最少使用) 缓存机制 。 实现 LRUCache 类: LRUCache(int capacity) 以正整数作为容量capacity 初始化 LRU 缓存 int get(int key) 如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。 void put(int key, int value)如果关键字已经存在,则变更其数据值;如果关键字不存在,则插入该组「关键字-值」。当缓存容量达到上限时,它应该在写入新数据...原创 2021-03-04 19:57:19 · 248 阅读 · 1 评论 -
leetcode 链表题目
1、翻转链表 链接:https://leetcode-cn.com/problems/reverse-linked-list/ /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode原创 2020-12-22 17:35:50 · 102 阅读 · 0 评论