17.09第k个数 Posted on 2020-04-20 | In bfs Words count in article: 157 | Reading time ≈ 1 下面是题目 下面是题目给出的模板123456class Solution {public: int getKthMagicNumber(int k) { }}; 用BFS+set可以完美遍历,真的太爽了12345678910111213 ... Read more »
933最近的请求次数 Posted on 2020-04-20 Words count in article: 189 | Reading time ≈ 1 933最近请求次数下面是题目 下面是题目给出的代码1234567891011121314151617class RecentCounter {public: RecentCounter() { } int ping(int t) { ... Read more »
621任务调度器 Posted on 2020-04-20 Words count in article: 1.1k | Reading time ≈ 4 621 任务调度器下面是题目 下面是题目给出的代码模板123456class Solution {public: int leastInterval(vector<char>& tasks, int n) { }} ... Read more »
206反转链表 Posted on 2020-04-20 Words count in article: 561 | Reading time ≈ 2 206反转链表写在前面 这篇的原文也在搭建博客中不幸牺牲 但是我还会简单注释一下 反转链表的作用很多,可以当作别的题目的子函数,比如回文,分隔等等 下面是题目 下面是题目给出的代码123456789101112131415/** * Definition for singly-linked li ... Read more »
160相交lianbiao Posted on 2020-04-20 Words count in article: 396 | Reading time ≈ 1 160 相交链表下面是题目 下面是题目给出的代码1234567891011121314/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ... Read more »
141环形链表 Posted on 2020-04-20 Words count in article: 385 | Reading time ≈ 1 141环形链表写在前面 因为原稿在操作时不慎丢失,所以忍痛再写!肯定不会比之前详细了 下面是题目 下面是题目给出的代码1234567891011121314/** * Definition for singly-linked list. * struct ListNode { * ... Read more »
如何用数组来控制指针实现链表 Posted on 2020-04-20 Words count in article: 3.3k | Reading time ≈ 15 如何用数组来控制指针实现链表.md 我们一般看到的链表定义都是这样的 12345struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} ... Read more »
当没有dummynode时实现链表头插 Posted on 2020-04-20 Words count in article: 93 | Reading time ≈ 1 如何实现链表的头插?12345678910111213// 链表一般是尾插的,那么怎么实现头插呢?void insertFromHead(ListNode* head){ //比如我要新插入一个节点 newNode,值为1; //先建立一个临时节点prev,让prev指向hea ... Read more »