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], which ...
分类:
其他好文 时间:
2018-10-20 12:15:36
阅读次数:
147
思路: floyed判环法。 https://www.youtube.com/watch?v=LUm2ABqAs1w 实现: ...
分类:
其他好文 时间:
2018-10-20 00:46:47
阅读次数:
143
一、题目 1、审题 2、分析 将链表中值为 val 的节点去除。 二、解答 1、思路: 方法一、 创建一个头结点,将后边的值为 val 的节点一一删除。 优化: 采用 pre、cur 指针,使代码更简洁 方法二、 采用递归 ...
分类:
其他好文 时间:
2018-10-19 23:40:44
阅读次数:
171
Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? ...
分类:
其他好文 时间:
2018-10-18 16:52:36
阅读次数:
111
Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right pointers as synonymous to the previous and next pointers i ...
分类:
其他好文 时间:
2018-10-18 10:57:59
阅读次数:
180
【2】Add Two Numbers 【19】Remove Nth Node From End of List 【21】Merge Two Sorted Lists 【23】Merge k Sorted Lists 【24】Swap Nodes in Pairs 【25】Reverse Nodes ...
分类:
其他好文 时间:
2018-10-16 13:41:14
阅读次数:
240
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 ...
分类:
其他好文 时间:
2018-10-16 10:16:21
阅读次数:
162
Given a constant K and a singly linked list L, you are supposed to reverse the links of every Kelements on L. For example, given L being 1→2→3→4→5→6, ...
分类:
其他好文 时间:
2018-10-15 14:57:57
阅读次数:
171
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 algo ...
分类:
其他好文 时间:
2018-10-14 14:15:45
阅读次数:
119
题目 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 ...
分类:
其他好文 时间:
2018-10-14 14:08:12
阅读次数:
160