feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent d65ccf7dc2
commit 0262ca8bf6
203 changed files with 4526 additions and 0 deletions

View File

@@ -11,6 +11,28 @@ patterns:
- binary-search
- two-pointers
function_signature: "def find_closest_elements(arr: list[int], k: int, x: int) -> list[int]:"
test_cases:
visible:
- input: { arr: [1, 2, 3, 4, 5], k: 4, x: 3 }
expected: [1, 2, 3, 4]
- input: { arr: [1, 1, 2, 3, 4, 5], k: 4, x: -1 }
expected: [1, 1, 2, 3]
hidden:
- input: { arr: [1], k: 1, x: 1 }
expected: [1]
- input: { arr: [1, 2, 3, 4, 5], k: 4, x: -1 }
expected: [1, 2, 3, 4]
- input: { arr: [1, 2, 3, 4, 5], k: 4, x: 10 }
expected: [2, 3, 4, 5]
- input: { arr: [1, 2, 3, 4, 5], k: 5, x: 3 }
expected: [1, 2, 3, 4, 5]
- input: { arr: [1, 1, 1, 10, 10, 10], k: 1, x: 9 }
expected: [10]
- input: { arr: [-2, -1, 1, 2, 3, 4, 5], k: 3, x: 0 }
expected: [-1, 1, 2]
description: |
Given a **sorted** integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ascending order.