feat(content): function signatures + test cases

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

View File

@@ -10,6 +10,26 @@ categories:
patterns:
- heap
function_signature: "def k_closest(points: list[list[int]], k: int) -> list[list[int]]:"
test_cases:
visible:
- input: { points: [[1, 3], [-2, 2]], k: 1 }
expected: [[-2, 2]]
- input: { points: [[3, 3], [5, -1], [-2, 4]], k: 2 }
expected: [[3, 3], [-2, 4]]
hidden:
- input: { points: [[0, 0]], k: 1 }
expected: [[0, 0]]
- input: { points: [[1, 1], [2, 2], [3, 3]], k: 3 }
expected: [[1, 1], [2, 2], [3, 3]]
- input: { points: [[1, 0], [0, 1]], k: 2 }
expected: [[1, 0], [0, 1]]
- input: { points: [[-5, 4], [3, 2], [1, 1], [0, 2]], k: 2 }
expected: [[1, 1], [0, 2]]
- input: { points: [[10, 10], [-10, -10], [1, 1]], k: 1 }
expected: [[1, 1]]
description: |
Given an array of `points` where `points[i] = [x_i, y_i]` represents a point on the **X-Y** plane and an integer `k`, return the `k` closest points to the origin `(0, 0)`.