Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 70114d5

Browse files
🐱(sw): 219. 存在重复元素 II
复盘
1 parent 94fa529 commit 70114d5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎docs/algorithm/sliding-window/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ class Solution(object):
3131
return False
3232
```
3333

34+
超时方法:
35+
36+
```python
37+
class Solution:
38+
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
39+
length = len(nums)
40+
i = 0
41+
while i < length:
42+
j = i + 1
43+
while j < length and j <= i + k:
44+
if nums[i] == nums[j]:
45+
return True
46+
j += 1
47+
i += 1
48+
return False
49+
```
50+
3451
## 239. 滑动窗口最大值
3552

3653
[原题链接](https://leetcode-cn.com/problems/sliding-window-maximum/)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /