![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LinkedList
weixin_39145266
这个作者很懒,什么都没留下…
展开
-
23 Merge k Sorted Lists
1 题目 Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3-...原创 2019-12-01 15:06:16 · 62 阅读 · 0 评论 -
445 Add Two Numbers II
1 题目 You are given twonon-emptylinked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and re...原创 2019-07-12 21:09:59 · 47 阅读 · 0 评论 -
328 Odd Even Linked List
1 题目 Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do i...原创 2019-07-03 00:05:04 · 43 阅读 · 0 评论 -
234 Palindrome Linked List
1 题目 Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) ...原创 2019-05-07 14:57:01 · 72 阅读 · 0 评论 -
206 Reverse Linked List
1 题目 Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively or re...原创 2019-04-26 15:54:21 · 59 阅读 · 0 评论 -
148 Sort List
1 题目 Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: ...原创 2019-04-22 13:32:11 · 54 阅读 · 0 评论 -
147 Insertion Sort List
1 题目 Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list. With each iteration on...原创 2019-04-22 12:49:12 · 88 阅读 · 0 评论 -
160 Intersection of Two Linked Lists
1 题目 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to intersect at node c1. Example 1: Inpu...原创 2019-04-26 11:42:17 · 84 阅读 · 0 评论 -
143 Reorder List
1 题目 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-...原创 2019-04-22 11:46:33 · 62 阅读 · 0 评论 -
109 Convert Sorted List to Binary Search Tree
1 题目 convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than ...原创 2019-04-17 11:26:42 · 68 阅读 · 0 评论 -
86 Partition List
1 题目 Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox. You should preserve the original relative order of the nodes in eac...原创 2019-03-29 09:16:55 · 53 阅读 · 0 评论 -
138 Copy List with Random Pointer
1 题目 A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return adeep copyof the list. Example 1: Input: {"$...原创 2019-04-02 14:01:21 · 88 阅读 · 0 评论 -
82 Remove Duplicates from Sorted List II
1 题目 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list. Example 1: Input: 1->2->3->3->4->4->5 Output:...原创 2019-03-29 09:17:55 · 33 阅读 · 0 评论 -
24 Swap Nodes in Pairs
1 题目 Given alinked list, swap every two adjacent nodes and return its head. You maynotmodify the values in the list's nodes, only nodes itself may be changed. 2 尝试解 /** * Definition for singl...原创 2019-03-29 09:18:04 · 43 阅读 · 0 评论 -
92 Reverse Linked List II
1 题目 Reverse a linked list from positionmton. Do it in one-pass. Note:1 ≤m≤n≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2-...原创 2019-03-30 11:28:00 · 41 阅读 · 0 评论 -
61 Rotate List
1 题目 Given a linkedlist, rotate the list to the right bykplaces, wherekis non-negative. 2 尝试解 class Solution { public: ListNode* rotateRight(ListNode* head, int k) { if(head == NU...原创 2019-03-29 09:16:15 · 40 阅读 · 0 评论 -
142 Linked List Cycle II
1 题目 Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. To represent a cycle in the given linked list, we use an integerposwhich represents the positio...原创 2019-03-29 15:21:34 · 54 阅读 · 0 评论