Skip to content

Commit d5aea89

Browse files
committed
update: 0287
1 parent dd4490d commit d5aea89

File tree

5 files changed

+6
-22
lines changed

5 files changed

+6
-22
lines changed

0287 Find the Duplicate Number/0287 Find the Duplicate Number.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,6 @@
6060
### Thought Process
6161

6262
1. two for loop to check the numbers
63-
- Implement
64-
65-
```python
66-
class Solution:
67-
def findDuplicate(self, nums: List[int]) -> int:
68-
"""
69-
1. using Gauss Algorithm $sum=(1+n)*(n)/2$
70-
2. sum the array
71-
3. subtract the summation of input array and the without one
72-
"""
73-
74-
sumWithoutDuplicate = (1 + len(nums) - 1)*(len(nums) - 1)/2
75-
sum = 0
76-
for num in nums:
77-
sum += num
78-
return int(sum - sumWithoutDuplicate)
79-
```
80-
8163

8264
### Complexity
8365

@@ -132,6 +114,8 @@
132114

133115
![Untitled](./Untitled%201.png)
134116

117+
![Untitled](./Untitled%202.png)
118+
135119
- 運用此原理進行 Binary search 找出重複的值
136120
1. lowerBound = 1, upperBound= len(nums) - 1
137121
2. 當 lowerBound < upperBound
@@ -186,15 +170,15 @@
186170

187171
- 原理
188172

189-
![Untitled](./Untitled%202.png)
173+
![Untitled](./Untitled%203.png)
190174

191175
- Linked List Cycle Detection
192176

193-
![Untitled](./Untitled%203.png)
177+
![Untitled](./Untitled%204.png)
194178

195179
- Find the entry point of the cycle
196180

197-
![Untitled](./Untitled%204.png)
181+
![Untitled](./Untitled%205.png)
198182

199183
- implement
200184

@@ -249,4 +233,4 @@
249233
```
250234

251235
- [Leetcode 287 Find the Duplicate Number](https://www.youtube.com/watch?v=zQ6eAdtDeqg)
252-
- **[LeetCode 287 Find the Duplicate Number (Python)](https://maxming0.github.io/2020/06/25/Find-the-Duplicate-Number/)**
236+
- [LeetCode 287 Find the Duplicate Number (Python)](https://maxming0.github.io/2020/06/25/Find-the-Duplicate-Number/)
-51 KB
Loading
89.2 KB
Loading
-24.9 KB
Loading
137 KB
Loading

0 commit comments

Comments
 (0)