木落长安rr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  LeetCode之链表LinkedList

摘要:Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be ch 阅读全文
posted @ 2019-04-01 21:26 木落长安rr 阅读(241) 评论(0) 推荐(0)

摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list -- head = [4,5,1,9], wh 阅读全文
posted @ 2019-03-29 15:23 木落长安rr 阅读(156) 评论(0) 推荐(0)

摘要:Remove all elements from a linked list of integers that have value val. Example: 本题的思路很简单,就是单纯的删除链表元素操作,如果头结点的元素就是给定的val值,需要借助虚结点dummy去判断。 方法一:(C++) C 阅读全文
posted @ 2019-03-29 15:13 木落长安rr 阅读(159) 评论(0) 推荐(0)

摘要:Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first elem 阅读全文
posted @ 2019-03-29 10:58 木落长安rr 阅读(241) 评论(0) 推荐(0)

摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use 阅读全文
posted @ 2019-03-29 10:05 木落长安rr 阅读(178) 评论(0) 推荐(0)

摘要: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 阅读全文
posted @ 2019-03-23 16:05 木落长安rr 阅读(127) 评论(0) 推荐(0)

摘要:Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: 根据经验,先建立一个虚结点dummy node,连上原链表的头结点,这样的话就算头结点变 阅读全文
posted @ 2019-03-23 11:29 木落长安rr 阅读(291) 评论(0) 推荐(0)

摘要:Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer poswhich represents the posit 阅读全文
posted @ 2019-03-23 10:42 木落长安rr 阅读(333) 评论(0) 推荐(0)

摘要:Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 解法二(C++) 阅读全文
posted @ 2019-03-22 11:50 木落长安rr 阅读(302) 评论(0) 推荐(0)