feat(content): function signatures + test cases
This commit is contained in:
@@ -9,6 +9,30 @@ categories:
|
||||
patterns:
|
||||
- sliding-window
|
||||
|
||||
function_signature: "def contains_nearby_duplicate(nums: list[int], k: int) -> bool:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { nums: [1, 2, 3, 1], k: 3 }
|
||||
expected: true
|
||||
- input: { nums: [1, 0, 1, 1], k: 1 }
|
||||
expected: true
|
||||
- input: { nums: [1, 2, 3, 1, 2, 3], k: 2 }
|
||||
expected: false
|
||||
hidden:
|
||||
- input: { nums: [1], k: 1 }
|
||||
expected: false
|
||||
- input: { nums: [1, 1], k: 0 }
|
||||
expected: false
|
||||
- input: { nums: [1, 2, 1], k: 2 }
|
||||
expected: true
|
||||
- input: { nums: [99, 99], k: 2 }
|
||||
expected: true
|
||||
- input: { nums: [1, 2, 3, 4, 5], k: 3 }
|
||||
expected: false
|
||||
- input: { nums: [0, 1, 2, 3, 4, 0, 0, 7, 8, 9, 10, 11, 12, 0], k: 1 }
|
||||
expected: true
|
||||
|
||||
description: |
|
||||
Given an integer array `nums` and an integer `k`, return `true` *if there are two **distinct indices*** `i` *and* `j` *in the array such that* `nums[i] == nums[j]` *and* `abs(i - j) <= k`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user