链表
HELLO_蓝猫
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
链表反转
在知乎上看见浙大查重被查了这道题,写了一下。面试常见的一道题。 原链表:head->1->2->3->null 方法:遍历一次,头插法重新排列。 head->null head->1->null .... head->3->2->1->null #include <iostream> #include &...原创 2017-12-22 21:54:55 · 316 阅读 · 0 评论 -
Leetcode 61. Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. Example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. 此题题目描述不清 踩的很多/** * Definition for si原创 2017-12-27 20:12:03 · 180 阅读 · 0 评论 -
Leetcode 82. Remove Duplicates from Sorted List II
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode deleteDupli...原创 2018-03-13 11:33:20 · 177 阅读 · 0 评论 -
Leetcode 86. Partition List
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode partition(L...原创 2018-03-20 14:31:07 · 205 阅读 · 0 评论 -
Leetcode 109. Convert Sorted List to Binary Search Tree
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ /** * Definition for a binary tree node. * pub...原创 2018-05-04 14:06:35 · 169 阅读 · 0 评论 -
Leetcode 147. Insertion Sort List
解法:找一个代排序列,一个排好序列,然后一个个比较,插入正确位置,重要一点,没插入完一个元素要更新rear的next。Sort a linked list using insertion sort.A graphical example of insertion sort. The partial sorted list (black) initially contains only the fi...原创 2018-06-26 15:40:13 · 225 阅读 · 0 评论 -
Leetcode 160. Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ c...原创 2018-07-09 11:10:32 · 162 阅读 · 0 评论 -
LRU缓存 Leetocde146. LRU Cache
class Node { public: int key_t; int value_t; Node(int key,int value):key_t(key),value_t(value) { } }; class LRUCache { public: list<Node> cache;//缓存 双向链表 方便插入...原创 2019-03-14 21:18:39 · 218 阅读 · 0 评论 -
链表中倒数第k个结点
#include <iostream> #include <memory> using namespace std; typedef struct LinkList { int val; shared_ptr<LinkList> next;//智能指针和普通指针不要混合使用 https://blog.youkuaiyun.com/flowing_wind/articl...原创 2019-07-25 16:35:41 · 214 阅读 · 0 评论
分享