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

@@ -8,6 +8,22 @@ categories:
patterns:
- heap
function_signature: "class TimeLimitedCache { set(key: number, value: number, duration: number): boolean; get(key: number): number; count(): number; }"
test_cases:
visible:
- input: { actions: ["TimeLimitedCache", "set", "get", "count", "get"], values: [[], [1, 42, 100], [1], [], [1]], timeDelays: [0, 0, 50, 50, 150] }
expected: [null, false, 42, 1, -1]
- input: { actions: ["TimeLimitedCache", "set", "set", "get", "get", "get", "count"], values: [[], [1, 42, 50], [1, 50, 100], [1], [1], [1], []], timeDelays: [0, 0, 40, 50, 120, 200, 250] }
expected: [null, false, true, 50, 50, -1, 0]
hidden:
- input: { actions: ["TimeLimitedCache", "set", "count", "set", "count"], values: [[], [1, 10, 100], [], [2, 20, 100], []], timeDelays: [0, 0, 0, 0, 0] }
expected: [null, false, 1, false, 2]
- input: { actions: ["TimeLimitedCache", "get"], values: [[], [1]], timeDelays: [0, 0] }
expected: [null, -1]
- input: { actions: ["TimeLimitedCache", "set", "set", "get"], values: [[], [1, 100, 50], [1, 200, 100], [1]], timeDelays: [0, 0, 25, 75] }
expected: [null, false, true, 200]
description: |
Write a class that allows getting and setting key-value pairs, however a **time until expiration** is associated with each key.