leetcode整理 Linked List
StudyCoder
这个作者很懒,什么都没留下…
展开
-
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 ↘转载 2016-06-02 16:39:41 · 206 阅读 · 0 评论 -
203. Remove Linked List Elements
题目:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5题意:删除链表中值为给定值转载 2016-06-09 14:25:30 · 189 阅读 · 0 评论 -
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转载 2016-06-09 13:47:28 · 203 阅读 · 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.题意:合并两个已经排好序的链表并作为一个新链表返回.思路一:利用递归实现转载 2016-06-08 16:25:44 · 198 阅读 · 0 评论 -
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.题意:给定一个排好序的链转载 2016-06-03 16:17:39 · 272 阅读 · 0 评论 -
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转载 2016-06-08 15:41:06 · 211 阅读 · 0 评论 -
141. 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?题意:给定一个链表,检测该链表是否是循环链表Follow up:是否能够不使用额外内存空间解决。思路: 1、最容易转载 2016-06-03 16:02:43 · 179 阅读 · 0 评论 -
234. Palindrome Linked List
题目:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?题意:给定一个单链表,检测其是否是回文链表Follow up:是否做到时间复杂度为O(n),空间复杂度为O(1);转载 2016-06-03 13:38:14 · 172 阅读 · 0 评论 -
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 w转载 2016-06-03 10:42:25 · 169 阅读 · 0 评论 -
206. Reverse Linked List
题目:Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?题意:翻转链表。该题可以采用轮询跟递归调用两种方转载 2016-06-09 15:06:00 · 197 阅读 · 0 评论