Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both?反转链表。有两种方法 ...
分类:
其他好文 时间:
2018-10-27 14:45:24
阅读次数:
93
19. Remove Nth Node From End of List 删除倒数第N个结点 21. Merge Two Sorted Lists 合并两个有序链表 141. Linked List Cycle 检查链表中是否有环 206. Reverse Linked List 反转链表 876. ...
分类:
编程语言 时间:
2018-10-27 13:23:07
阅读次数:
191
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-27 11:59:22
阅读次数:
122
LRU的典型实现是hash map + doubly linked list, 双向链表用于存储数据结点,并且它是按照结点最近被使用的时间来存储的。 如果一个结点被访问了, 我们有理由相信它在接下来的一段时间被访问的概率要大于其它结点。于是, 我们把它放到双向链表的头部。当我们往双向链表里插入一个结... ...
分类:
系统相关 时间:
2018-10-25 11:02:54
阅读次数:
168
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2: ...
分类:
其他好文 时间:
2018-10-24 20:00:48
阅读次数:
157
概念介绍 上一博文已经介绍了Python实现单向无序链表的实现方式,这篇博文来介绍Python如何实现单向有序链表。有序和无序仅仅指节点所包含的数据成员的大小排列顺序,有序指各个节点按照节点数据成员的大小顺序排序,从大到小或从小到大。无序则可以任意排列。 链表节点实现 实现方式完全同单向无序列表,这 ...
分类:
编程语言 时间:
2018-10-24 01:14:28
阅读次数:
393
快慢指针简述 快慢指针经常用于链表(linked list)中环(Cycle)相关的问题。 1. 快指针(fast pointer)和慢指针(slow pointer)都从链表的head出发。 1. slow pointer每次移动一格,而快指针每次移动两格。 1. 如果快慢指针能相遇,则证明链表中 ...
分类:
编程语言 时间:
2018-10-23 14:39:59
阅读次数:
209
Given a non empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middl ...
分类:
其他好文 时间:
2018-10-22 14:54:43
阅读次数:
100
/** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNod... ...
分类:
其他好文 时间:
2018-10-21 21:48:34
阅读次数:
116
一、题目 1、审题 2、分析 分别采用递归、迭代的方式将链表进行翻转。 二、解答 1、思路: 方法一、 迭代: 采用两个指针 pre、cur 方法二、 递归: ...
分类:
其他好文 时间:
2018-10-20 19:52:58
阅读次数:
153