
链表
acttell
这个作者很懒,什么都没留下…
展开
-
leetcode Merge k Sorted Lists 合并k个有序链表
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路:建一个大小为K的小顶堆(优先队列默认大顶堆,需要自定义降序,变成小顶堆),先把K个链表的头结点扔进堆,取了堆顶元素后,接着把堆顶元素所在链表的非空结点扔进堆。 #include <iost...原创 2018-06-21 02:17:23 · 186 阅读 · 0 评论 -
leetcode Rotate List 旋转链表
http://www.cnblogs.com/grandyang/p/4355505.html原创 2018-10-02 19:57:24 · 234 阅读 · 0 评论 -
链表中是否有环 单链表中环的问题
https://www.cnblogs.com/dancingrain/p/3405197.html原创 2018-09-03 08:16:46 · 210 阅读 · 0 评论 -
链表倒数第k个结点
https://blog.youkuaiyun.com/lks1139230294/article/details/52775517原创 2018-09-03 07:34:14 · 135 阅读 · 0 评论 -
奇数位升序偶数位降序 链表排序
https://www.cnblogs.com/DarrenChan/p/8764608.html原创 2018-08-28 09:01:25 · 6542 阅读 · 0 评论 -
leetcode Sort List 链表归并排序
http://www.cnblogs.com/grandyang/p/4249905.html原创 2018-08-28 08:31:52 · 236 阅读 · 0 评论 -
leetcode Add Two Numbers 链表加法
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a l...原创 2018-08-28 07:31:20 · 165 阅读 · 0 评论 -
剑指offer 两链表的第一个公共结点
思路: 如果两个单向链表l1 l2有公共结点, 那么l1 l2从某一结点开始,它们next指向公共结点。 从公共结点开始后面所有结点均重合。 分别遍历l1 l2得到它们的长度n1 n2,并求出|n1-n2|。 在长链表上先遍历|n1-n2|,再同步遍历l1 l2,直到找到相同的结点。 时间复杂度为O(n1+n2)。...原创 2018-06-28 08:35:06 · 131 阅读 · 0 评论 -
链表逆序
思路:3个辅助指针,不断移动指针位置 #include <iostream> using namespace std; typedef struct Node { int val; struct Node* next; }node; node* reverse(node* head) { node* p=NULL; node* q=NULL; ...原创 2018-06-22 01:50:26 · 139 阅读 · 0 评论 -
leetcode 合并两个有序链表
题目:链表A和B都升序,合并为一个升序的链表。 思路:递归 #include &amp;amp;lt;iostream&amp;amp;gt; using namespace std; typedef struct Node { int val; struct Node* next; }node; node* merge(node* a,node* b) { if(a==NULL) r...原创 2018-06-22 01:26:05 · 194 阅读 · 0 评论 -
以x为基准将链表分割,前小后大
https://blog.youkuaiyun.com/HelloZEX/article/details/81126071?utm_source=blogxgwz6原创 2018-10-21 14:42:48 · 690 阅读 · 0 评论