链表
zhaohoutao
这个作者很懒,什么都没留下…
展开
-
LeetCode-142 链表环
链表相交 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNo...原创 2019-06-28 09:43:25 · 109 阅读 · 0 评论 -
LeetCode 138 复制带随机指针的链表
复制带随机指针的链表 /* // Definition for a Node. class Node { public: int val; Node* next; Node* random; Node() {} Node(int _val, Node* _next, Node* _random) { val = _val; ...原创 2019-08-12 13:27:35 · 71 阅读 · 0 评论 -
LeetCode 25 K 个一组翻转链表
K 个一组翻转链表 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: L...原创 2019-08-11 21:41:29 · 60 阅读 · 0 评论 -
LeetCode 82 删除排序链表中的重复元素 II
删除排序链表中的重复元素 II /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public:...原创 2019-08-14 20:28:26 · 76 阅读 · 0 评论 -
LeetCode 61 旋转链表
旋转链表 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNo...原创 2019-08-14 18:24:31 · 64 阅读 · 0 评论 -
LeetCode 148 排序链表
排序链表 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNo...原创 2019-08-09 14:46:07 · 72 阅读 · 0 评论 -
LeetCode 109 有序链表转换二叉搜索树
有序链表转换二叉搜索树 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ /** * Definition for a bina...原创 2019-07-20 23:26:04 · 73 阅读 · 0 评论 -
LeetCode 203 移除链表元素
移除链表元素 /** Definition for singly-linked list. struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; / class Solution { public: ListNode removeElements(ListNo...原创 2019-07-16 23:01:15 · 92 阅读 · 0 评论 -
LeetCode 234 回文链表
回文链表 自己的代码超出时间 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ...原创 2019-07-16 20:43:56 · 58 阅读 · 0 评论 -
LeetCode-237 删除链表中的节点
删除链表中的节点 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: vo...原创 2019-07-18 23:34:19 · 54 阅读 · 0 评论 -
LeetCode-24 两两交换链表中的节点
两两交换链表中的节点 对于链表题的注意事项: 1.对于跳跃型的链表需要判断node!=NULL&&node->next!=NULL 2.操作链表的时候需要的时候一定要要拷贝一份头指针 3.需要拷贝一下下一个节点,因为可能会因为删除next指针导致断链了 /** * Definition for singly-linked list. * struct ListNode ...原创 2019-07-09 22:55:50 · 56 阅读 · 0 评论 -
LeetCode-23 合并k个排序链表
合并k个排序链表 使用暴力求解 使用分治法,递归 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solutio...原创 2019-06-28 23:37:39 · 87 阅读 · 0 评论 -
LeetCode-86 分割链表
分割链表 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNo...原创 2019-06-28 22:39:32 · 104 阅读 · 0 评论 -
二叉树转换成链表和搜索二叉树转换成双链表
`二叉树转换成链表`` /** Definition for a binary tree node. struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; / class Solution { p...原创 2019-08-28 14:28:43 · 179 阅读 · 0 评论