feat(content): more test cases

This commit is contained in:
2025-07-13 19:25:39 +01:00
parent d2b74b6863
commit 85fea3a4bb
94 changed files with 1840 additions and 0 deletions

View File

@@ -11,6 +11,24 @@ categories:
patterns:
- heap
function_signature: "def top_k_frequent(nums: list[int], k: int) -> list[int]:"
test_cases:
visible:
- input: { nums: [1, 1, 1, 2, 2, 3], k: 2 }
expected: [1, 2]
- input: { nums: [1], k: 1 }
expected: [1]
- input: { nums: [4, 1, -1, 2, -1, 2, 3], k: 2 }
expected: [-1, 2]
hidden:
- input: { nums: [1, 2], k: 2 }
expected: [1, 2]
- input: { nums: [5, 5, 5, 5, 5], k: 1 }
expected: [5]
- input: { nums: [1, 1, 2, 2, 3, 3, 4], k: 3 }
expected: [1, 2, 3]
description: |
Given an integer array `nums` and an integer `k`, return *the* `k` *most frequent elements*. You may return the answer in **any order**.