feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent eb7c731af0
commit 323a1aa50e
203 changed files with 4526 additions and 0 deletions
@@ -9,6 +9,26 @@ categories:
patterns:
- heap
function_signature: "class MedianFinder:\n def __init__(self): ...\n def add_num(self, num: int) -> None: ...\n def find_median(self) -> float: ..."
test_cases:
visible:
- input: { operations: ["MedianFinder", "addNum", "addNum", "findMedian", "addNum", "findMedian"], arguments: [[], [1], [2], [], [3], []] }
expected: [null, null, null, 1.5, null, 2.0]
- input: { operations: ["MedianFinder", "addNum", "findMedian"], arguments: [[], [5], []] }
expected: [null, null, 5.0]
hidden:
- input: { operations: ["MedianFinder", "addNum", "addNum", "addNum", "addNum", "addNum", "findMedian"], arguments: [[], [1], [2], [3], [4], [5], []] }
expected: [null, null, null, null, null, null, 3.0]
- input: { operations: ["MedianFinder", "addNum", "addNum", "findMedian"], arguments: [[], [-1], [-2], []] }
expected: [null, null, null, -1.5]
- input: { operations: ["MedianFinder", "addNum", "addNum", "addNum", "addNum", "findMedian"], arguments: [[], [1], [1], [1], [1], []] }
expected: [null, null, null, null, null, 1.0]
- input: { operations: ["MedianFinder", "addNum", "findMedian", "addNum", "findMedian", "addNum", "findMedian"], arguments: [[], [6], [], [10], [], [2], []] }
expected: [null, null, 6.0, null, 8.0, null, 6.0]
- input: { operations: ["MedianFinder", "addNum", "addNum", "addNum", "findMedian"], arguments: [[], [-100000], [100000], [0], []] }
expected: [null, null, null, null, 0.0]
description: |
The **median** is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values.