随笔分类 -  linked list(reverse)

24. Swap Nodes in Pairs
摘要:Given a linked list, swap every two adjacent nodes and return its head. Example: Given 1->2->3->4, you should return the list as 2->1->4->3. Note: * Your algorithm should use only constant extra spac... 阅读全文

posted @ 2018-11-09 07:19 猪猪🐷

234. Palindrome Linked List
摘要:Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time and O(1) space? ... 阅读全文

posted @ 2018-11-09 07:18 猪猪🐷

Swap Nodes in Pairs
摘要:Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You may no 阅读全文

posted @ 2018-08-28 21:23 猪猪🐷

92. Reverse Linked List II
摘要:Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: 阅读全文

posted @ 2018-08-09 18:22 猪猪🐷

25. Reverse Nodes in k-Group
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文

posted @ 2018-08-09 18:20 猪猪🐷

206. Reverse Linked List
摘要:Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 阅读全文

posted @ 2018-07-18 09:10 猪猪🐷

导航