
LeetCode-LinkedList
R_zz
这个作者很懒,什么都没留下…
展开
-
LeetCode-LinkedList-141. Linked List Cycle
问题:https://leetcode.com/problems/linked-list-cycle/ Given a linked list, determine if it has a cycle in it. 分析:如果无环,遍历链表将会走到NULL的位置。如果有环,用两个指针,fast和slow。fast一次走两步,slow一次走一步。fast先出发,slow后出发。再把slow看成在前原创 2017-01-18 10:56:58 · 240 阅读 · 0 评论 -
LeetCode-LinkedList-237. Delete Node in a Linked List
问题:https://leetcode.com/problems/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原创 2017-01-18 11:08:27 · 200 阅读 · 0 评论 -
LeetCode-LinkedList-24. Swap Nodes in Pairs
问题:https://leetcode.com/problems/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.原创 2017-01-19 15:50:12 · 245 阅读 · 0 评论 -
LeetCode-206. Reverse Linked List
问题: https://leetcode.com/problems/reverse-linked-list/?tab=Description Reverse a singly linked list.反转一个单向链表。 参考C++代码:/** * Definition for singly-linked list. * struct ListNode { * int val;原创 2017-03-02 16:59:48 · 224 阅读 · 0 评论 -
LeetCode-203. Remove Linked List Elements
问题: https://leetcode.com/problems/remove-linked-list-elements/?tab=Description Remove all elements from a linked list of integers that have value val. 删除值为val的元素。 Example: Given: 1 –> 2 –> 6 –> 3 –原创 2017-03-03 11:02:47 · 237 阅读 · 0 评论 -
LeetCode-21. Merge Two Sorted Lists
问题: https://leetcode.com/problems/merge-two-sorted-lists/?tab=Description 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原创 2017-03-03 11:16:03 · 226 阅读 · 0 评论 -
LeetCode-83. Remove Duplicates from Sorted List
问题: https://leetcode.com/problems/remove-duplicates-from-sorted-list/?tab=Description Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given原创 2017-03-03 17:11:40 · 216 阅读 · 0 评论