Linked List
文章平均质量分 60
Queen、
这个作者很懒,什么都没留下…
展开
-
LeetCode 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. 分析: 题目的意思将将两个已排序的链表合并成一个链表 定义一个链表头指针和连接指针。连接指针用原创 2017-09-25 19:28:48 · 245 阅读 · 0 评论 -
LeetCode 83. Remove Duplicates from Sorted List
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. 分析: 题目大意为将给定的已排序好的原创 2017-09-25 20:28:47 · 272 阅读 · 0 评论 -
LeetCode 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value原创 2017-09-28 20:25:32 · 224 阅读 · 0 评论 -
LeetCode 19. Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l原创 2017-09-28 22:11:17 · 242 阅读 · 0 评论 -
LeetCode 61. 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. 分析: 旋转链表,新链表的头节点应该是len-k%len原创 2017-10-02 22:11:50 · 238 阅读 · 0 评论 -
LeetCode 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You m原创 2017-10-02 22:19:40 · 255 阅读 · 0 评论