File tree 2 files changed +10
-8
lines changed
2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 6
6
* 分类:Hash Table, LinkedList
7
7
* 思路:一种用HashTable,把源节点和复制的节点对应起来,空间复杂度为O(n)
8
8
* 把要复制的节点直接连接在该节点之后,操作完以后再分开
9
- * Tips:和139做对比, 因为需要每步骤返回值,所以递归的方法在这题更合适
9
+ * Tips:因为需要每步骤返回值,所以递归的方法在这题更合适
10
10
*/
11
11
public class lc138 {
12
12
class RandomListNode {
Original file line number Diff line number Diff line change @@ -2,16 +2,18 @@ LeetCode 指南
2
2
===
3
3
4
4
- 语言: Java
5
- - 说明: 每道题在代码头部都添加了我的解题思路和想法 ,Eg:
5
+ - 说明: 每道题在代码头部都添加了我的解题思路和批注 ,Eg:
6
6
7
7
8
8
/*
9
- * 160. Intersection of Two Linked Lists
10
- * 题意:求两个链表的交叉点
11
- * 难度:Easy
12
- * 分类:LinkedList
13
- * 思路:两种方法:1.找出两个链表的长度差x,长的先走x步; 2.走完一个链表,走另一个链表,两个cur都走了两个链表长度的和步
14
- * Tips:两种方法的本质是一样的其实,都是找到了步数差,都遍历了两遍
9
+ * 287. Find the Duplicate Number
10
+ * 题意:n+1个数属于[1~n],找出重复的那个数
11
+ * 难度:Medium
12
+ * 分类:Array, Two Pointers, Binary Search
13
+ * 思路:如果nums[i]不在对应位置,则和对应位置交换。如果对应位置上也为该数,说明这个数就是重复的数字。这个方法改变了数组。是错误的。
14
+ * 另一种方法,把问题转换成有环链表,找环的起始节点。O(n) O(1) lc142
15
+ * 二分查找,每次看一边数字的个数, O(nlog(n)) O(1)
16
+ * Tips:剑指offer原题
15
17
*/
16
18
17
19
---
You can’t perform that action at this time.
0 commit comments