Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit ae58aab

Browse files
aQuaaQua
aQua
authored and
aQua
committed
219 finish
1 parent 35ff9fe commit ae58aab

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Algorithms/0219.contains-duplicate-ii/contains-duplicate-ii.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package Problem0219
22

33
func containsNearbyDuplicate(nums []int, k int) bool {
4+
if k <= 0 {
5+
return false
6+
}
7+
48
// 利用 m 记录 a[i]中的值,每次出现的(索引号+1)
59
m := make(map[int]int, len(nums))
610

Algorithms/0219.contains-duplicate-ii/contains-duplicate-ii_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ func Test_Problem0219(t *testing.T) {
3838
},
3939
},
4040

41+
question{
42+
para{
43+
[]int{1, 2, 3, 4, 5},
44+
0,
45+
},
46+
ans{
47+
false,
48+
},
49+
},
50+
4151
question{
4252
para{
4353
[]int{1, 2, 3, 4, 5},

0 commit comments

Comments
 (0)