![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linked List
文章平均质量分 58
violet_program
这个作者很懒,什么都没留下…
展开
-
Leetcode: Insertion Sort List
Sort a linked list using insertion sort. /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; *原创 2013-11-14 04:58:39 · 1439 阅读 · 0 评论 -
Swap Nodes In Pairs
public ListNode swapPairs(ListNode head) { // Start typing your Java solution below // DO NOT write main() function if(head == null) return head; if(head.next == null) return head; Lis转载 2013-05-17 05:28:13 · 467 阅读 · 0 评论 -
Leetcode: Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the follo原创 2013-06-26 11:44:01 · 796 阅读 · 0 评论 -
Reverse Nodes In K Group
public ListNode reverseKGroup(ListNode head, int k) { // Start typing your Java solution below // DO NOT write main() function if(head == null || k == 1) return head; ListNode cur = head;转载 2013-05-18 02:57:42 · 579 阅读 · 0 评论 -
Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. /** * Definition for singly-linked l原创 2013-06-11 04:21:47 · 458 阅读 · 0 评论 -
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原创 2013-06-20 11:54:30 · 507 阅读 · 0 评论 -
Remove Nth Node from End of List
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public转载 2013-05-15 04:14:08 · 565 阅读 · 0 评论 -
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. /** * Definition for singly-linked list. * public cla原创 2013-06-11 10:53:31 · 530 阅读 · 0 评论 -
Add Two Numbers
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public转载 2013-05-10 11:43:38 · 434 阅读 · 0 评论 -
Remove Duplicates from Sorted List I
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. /** * Definition for si原创 2013-06-18 05:42:52 · 467 阅读 · 0 评论 -
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. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->原创 2013-06-19 01:16:01 · 575 阅读 · 0 评论 -
Leetcode: 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 must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reorder it to {1,4原创 2013-11-11 10:44:24 · 793 阅读 · 0 评论 -
Leetcode: Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? /** * Definition for singly-linked list. * class ListNode { * int val; *原创 2013-11-11 10:41:53 · 779 阅读 · 0 评论 -
Copy List with Random Pointer
/* * 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 a deep copy of the list. */ public原创 2013-10-09 09:57:32 · 717 阅读 · 0 评论 -
Leetcode: Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space? /** * Definition for singly-linked list.原创 2013-11-11 10:43:31 · 828 阅读 · 0 评论 -
Merge K Sorted Lists
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public转载 2013-05-16 05:04:17 · 504 阅读 · 0 评论