
链表 栈 队列
csdnzhaocsdn
先通俗易懂
再简洁高效
菜但步履不停
所有文章只是学习用没有任何商业盈利若侵权我删
展开
-
148. 排序链表
在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序。示例 1:输入: 4->2->1->3输出: 1->2->3->4示例 2:输入: -1->5->3->4->0输出: -1->0->3->4->5来源:力扣(LeetCode)链接:https://leetcode-cn.c...原创 2020-02-06 11:18:51 · 84 阅读 · 0 评论 -
147. 对链表进行插入排序
对链表进行插入排序。插入排序算法:插入排序是迭代的,每次只移动一个元素,直到所有元素可以形成一个有序的输出列表。每次迭代中,插入排序只从输入数据中移除一个待排序的元素,找到它在序列中适当的位置,并将其插入。重复直到所有输入数据插入完为止。示例 1:输入: 4->2->1->3输出: 1->2->3->4示例 2:输入: -1->5->...原创 2020-02-05 23:34:01 · 95 阅读 · 0 评论 -
206. 反转链表
反转一个单链表。示例:输入: 1->2->3->4->5->NULL输出: 5->4->3->2->1->NULL进阶:你可以迭代或递归地反转链表。你能否用两种方法解决这道题?来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/reverse-linked-list著作权归...原创 2020-02-05 23:01:27 · 74 阅读 · 0 评论 -
203. 移除链表元素
删除链表中等于给定值 val 的所有节点。示例:输入: 1->2->6->3->4->5->6, val = 6输出: 1->2->3->4->5/** * Definition for singly-linked list. * public class ListNode { * int val; * L...原创 2020-02-05 22:52:29 · 69 阅读 · 0 评论 -
160. 相交链表
编写一个程序,找到两个单链表相交的起始节点。如下面的两个链表:在节点 c1 开始相交。示例 1:输入:intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3输出:Reference of the node with value = 8输入解释:相交节点的值为 8 (注意,如果两...原创 2020-02-05 22:48:17 · 79 阅读 · 0 评论 -
143. Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You may not modify the values in the list’s nodes, only nodes itself may be changed.Example 1:Given 1->2->...原创 2020-02-05 16:26:10 · 92 阅读 · 0 评论 -
142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-in...原创 2020-02-05 15:06:18 · 109 阅读 · 0 评论 -
92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5->...原创 2020-02-05 12:32:14 · 128 阅读 · 0 评论 -
86. Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of th...原创 2020-02-05 11:53:18 · 89 阅读 · 0 评论 -
82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output: 1->2-...原创 2020-02-04 22:26:04 · 88 阅读 · 0 评论 -
83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output: 1->2-&...原创 2020-02-04 22:11:00 · 72 阅读 · 0 评论 -
61. Rotate List
Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplanati...原创 2020-02-04 21:55:16 · 110 阅读 · 0 评论 -
24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes, only nodes itself may be changed.Example:Given 1->2->3->4, you sho...原创 2020-02-04 13:30:08 · 93 阅读 · 0 评论 -
21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1->...原创 2020-02-04 11:19:07 · 139 阅读 · 0 评论 -
19. Remove Nth Node From End of List
Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the l...原创 2020-02-04 10:59:28 · 74 阅读 · 0 评论 -
2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...原创 2020-02-04 10:16:32 · 87 阅读 · 0 评论