File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 62
62
| 205 | [ Isomorphic Strings] ( https://leetcode.com/problems/isomorphic-strings ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/IsomorphicStrings.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/isomorphic_strings.py ) |
63
63
| 206 | [ Reverse Linked Lists] ( https://leetcode.com/problems/reverse-linked-list ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/ReverseLinkedList.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/reverse_linked_list.py ) |
64
64
| 217 | [ Contains Duplicate] ( https://leetcode.com/problems/contains-duplicate ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/ContainsDuplicate.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/contains_duplicate.py ) |
65
- | 219 | [ Contains Duplicate II] ( https://leetcode.com/problems/contains-duplicate-ii ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/ContainsDuplicateII.java ) |
65
+ | 219 | [ Contains Duplicate II] ( https://leetcode.com/problems/contains-duplicate-ii ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/ContainsDuplicateII.java ) [ ![ Python ] ( https://img.icons8.com/color/35/000000/python.png )] ( python/contains_duplicate_ii.py ) |
66
66
| 225 | [ Implement Stack using Queues] ( https://leetcode.com/problems/implement-stack-using-queues ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/MyStack.java ) |
67
67
| 226 | [ Invert Binary Tree] ( https://leetcode.com/problems/invert-binary-tree ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/InvertBinaryTree.java ) |
68
68
| 231 | [ Power of Two] ( https://leetcode.com/problems/power-of-two ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/PowerOf2.java ) |
Original file line number Diff line number Diff line change
1
+ from typing import List
2
+
3
+
4
+ class Solution :
5
+ def containsNearbyDuplicate (self , nums : List [int ], k : int ) -> bool :
6
+ position = {}
7
+ for index , number in enumerate (nums ):
8
+ if number in position and abs (index - position [number ]) <= k :
9
+ return True
10
+ position [number ] = index
11
+ return False
You can’t perform that action at this time.
0 commit comments