执行用时 :180 ms, 在所有 python3 提交中击败了32.63%的用户 内存消耗 :13.9 MB, 在所有 python3 提交中击败了100.00%的用户 执行用时为 48 ms 的范例 # Definition for singly-linked list. # class Lis ...
分类:
其他好文 时间:
2019-10-24 13:13:57
阅读次数:
95
delete-node-in-a-linked-list 注释:这道题简直就是阅读理解 ...
分类:
其他好文 时间:
2019-10-23 13:18:58
阅读次数:
66
Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: The flattened tree should look like: ...
分类:
其他好文 时间:
2019-10-23 12:06:42
阅读次数:
102
反转一个单链表。 示例: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NU ...
分类:
其他好文 时间:
2019-10-21 23:24:54
阅读次数:
152
Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will always be valid. Follow up: Could you ...
分类:
其他好文 时间:
2019-10-21 09:25:57
阅读次数:
82
Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will always be valid. Follow up: Could you ...
分类:
其他好文 时间:
2019-10-16 23:20:06
阅读次数:
94
这类reverse的题不会写,会写homebrew也枉然。这题我用的是iterative的思路做的。创建一个空的指针pre。当head不为空的时候,先存住head.next,然后head.next指向pre,最后pre,head,next三个指针整体往后移动一位。代码如下,也share一个注释写的比 ...
分类:
其他好文 时间:
2019-10-14 12:31:47
阅读次数:
99
这题思路跟2很相似。唯一的不同点在于,2只是正向做加法,但是445是在逆向做加法。这题我的思路是先用stack存住两个list的nodes,然后pop出来的时候做加法。这样就不需要操心reverse linked list这件事了。 ...
分类:
其他好文 时间:
2019-10-13 15:07:06
阅读次数:
97
Easy 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 ...
分类:
其他好文 时间:
2019-10-10 10:29:24
阅读次数:
70
在实现JS版本之前我有实现过Java版本,很奇怪为什么discussion里面大多数JS版本的解法都没有用dummy node。 ...
分类:
其他好文 时间:
2019-10-09 09:43:37
阅读次数:
68