列表类型(List)可以存储一个有序的字符串列表,常用的操作就是向列表两端添加元素,或者获取列表中某一个片段。 列表类型内部使用双向链表(double linked list)实现的,所以向列表两端添加或删除元素的速度非常快,越是接近两端的元素就越快,但是,也有弊端,就是通过索引访问元素的速度比较慢 ...
分类:
其他好文 时间:
2019-01-27 19:09:16
阅读次数:
166
1.取linked list 中间值,用快慢指针 2.停止的条件是fast.next=none 和fast 一起来判断,因为fast是对偶数个,fast.next 是 针对奇数个的时候 ...
分类:
其他好文 时间:
2019-01-25 23:21:50
阅读次数:
223
算法描述: Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You ...
分类:
其他好文 时间:
2019-01-25 15:06:14
阅读次数:
167
算法描述: Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After ...
分类:
其他好文 时间:
2019-01-25 13:42:02
阅读次数:
169
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */class Solution { p ...
分类:
其他好文 时间:
2019-01-24 13:07:30
阅读次数:
129
Description Description 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 pos w ...
分类:
其他好文 时间:
2019-01-23 11:39:21
阅读次数:
167
/*23. 合并K个排序链表合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。示例:输入:[ 1->4->5, 1->3->4, 2->6]输出: 1->1->2->3->4->4->5->6 *//** * Definition for singly-linked list. ... ...
分类:
编程语言 时间:
2019-01-20 22:54:40
阅读次数:
173
https://leetcode.com/problems/linked-list-components/ We are given head, the head node of a linked list containing unique integer values. We are also ...
分类:
其他好文 时间:
2019-01-20 22:00:32
阅读次数:
179
https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ Given a sorted linked list, delete all nodes that have duplicate numbers, leaving ...
分类:
其他好文 时间:
2019-01-19 17:25:13
阅读次数:
196
/*将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。示例:输入:1->2->4, 1->3->4输出:1->1->2->3->4->4Definition for singly-linked list. public class ListNode { * ... ...
分类:
其他好文 时间:
2019-01-14 23:17:47
阅读次数:
343