feat(content): function signatures + test cases

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

View File

@@ -9,6 +9,26 @@ categories:
patterns:
- heap
function_signature: "class KthLargest:\n def __init__(self, k: int, nums: list[int]):\n def add(self, val: int) -> int:"
test_cases:
visible:
- input: { operations: ["KthLargest", "add", "add", "add", "add", "add"], arguments: [[3, [4, 5, 8, 2]], [3], [5], [10], [9], [4]] }
expected: [null, 4, 5, 5, 8, 8]
- input: { operations: ["KthLargest", "add", "add", "add", "add"], arguments: [[4, [7, 7, 7, 7, 8, 3]], [2], [10], [9], [9]] }
expected: [null, 7, 7, 7, 8]
hidden:
- input: { operations: ["KthLargest", "add"], arguments: [[1, []], [-3]] }
expected: [null, -3]
- input: { operations: ["KthLargest", "add", "add"], arguments: [[1, [1, 2, 3]], [4], [5]] }
expected: [null, 4, 5]
- input: { operations: ["KthLargest", "add", "add", "add"], arguments: [[2, [0]], [1], [2], [3]] }
expected: [null, 0, 1, 2]
- input: { operations: ["KthLargest", "add", "add"], arguments: [[3, [5, 5, 5]], [5], [5]] }
expected: [null, 5, 5]
- input: { operations: ["KthLargest", "add"], arguments: [[1, [-10000]], [10000]] }
expected: [null, 10000]
description: |
Design a class to find the `k`<sup>th</sup> largest element in a stream.