You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a ...
分类:
其他好文 时间:
2018-09-21 21:39:58
阅读次数:
276
Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Example 2: 与189. Rotate Array 类似,但链表不能通过index来访问,要一 ...
分类:
其他好文 时间:
2018-09-21 10:56:37
阅读次数:
161
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 ...
分类:
其他好文 时间:
2018-09-21 10:51:35
阅读次数:
173
发现简单题越来越少了,想偷懒都不可以了,今天的题目是中等难度的题目,题目如下: 这个题目是要根据链表的位置来修改链表,位置为奇数的节点全部排到前面,位置为偶数的节点全部排到奇数的后面,并且保持顺序不变。 想到的解决步骤为: 1、遍历数组,奇数的位置的节点组成一条新链表,偶数位置的节点组成另一个新链表 ...
分类:
其他好文 时间:
2018-09-18 13:06:07
阅读次数:
179
2018-09-11 22:58:29 问题描述: 问题求解: 反转链表一直是一个很经典的问题,本题中其实是最经典的全局反转的一个改进和加深,本题的求解思路完全可以套用到全局反转中。 本题实际使用的思路是一种插入的思路,维护了三个指针prev,cur,then。 prev : 初始位置的前一个位置, ...
分类:
其他好文 时间:
2018-09-12 00:01:53
阅读次数:
232
题目: Remove all elements from a linked list of integers that have value val. 从具有值val的整数的链接列表中删除所有元素。 Example: 解答: 详解: 设置虚拟头结点dummyHead,dummyHead.next=h ...
分类:
其他好文 时间:
2018-09-09 16:45:07
阅读次数:
110
Description Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: 问题描述:给定一个已排序链表,移除重复元素 代码: ...
分类:
其他好文 时间:
2018-09-08 22:38:19
阅读次数:
171
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 first two lis ...
分类:
其他好文 时间:
2018-09-08 22:26:16
阅读次数:
169
Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: 解法:归并排序。由于有时间和空间复杂度的要求。把链表从中间分开,递归下去,都最后两个node时开始合并,返回上一层 ...
分类:
编程语言 时间:
2018-09-08 15:26:38
阅读次数:
124
题目: Given a linked list, determine if it has a cycle in it. 给定一个链表,确定它是否有一个循环。 Follow up:Can you solve it without using extra space? 你能不用额外的空间解决它吗? 解答 ...
分类:
其他好文 时间:
2018-09-08 13:07:35
阅读次数:
153