feat(content): function signatures + test cases
This commit is contained in:
@@ -9,6 +9,26 @@ categories:
|
||||
patterns:
|
||||
- trie
|
||||
|
||||
function_signature: "class Trie"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { operations: ["Trie", "insert", "search", "search", "startsWith", "insert", "search"], arguments: [[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]] }
|
||||
expected: [null, null, true, false, true, null, true]
|
||||
hidden:
|
||||
- input: { operations: ["Trie", "insert", "search"], arguments: [[], ["hello"], ["hello"]] }
|
||||
expected: [null, null, true]
|
||||
- input: { operations: ["Trie", "search"], arguments: [[], ["nonexistent"]] }
|
||||
expected: [null, false]
|
||||
- input: { operations: ["Trie", "insert", "insert", "search", "search"], arguments: [[], ["abc"], ["ab"], ["abc"], ["ab"]] }
|
||||
expected: [null, null, null, true, true]
|
||||
- input: { operations: ["Trie", "insert", "startsWith", "startsWith"], arguments: [[], ["prefix"], ["pre"], ["pref"]] }
|
||||
expected: [null, null, true, true]
|
||||
- input: { operations: ["Trie", "insert", "startsWith"], arguments: [[], ["a"], ["b"]] }
|
||||
expected: [null, null, false]
|
||||
- input: { operations: ["Trie", "insert", "insert", "search", "startsWith"], arguments: [[], ["app"], ["apple"], ["ap"], ["ap"]] }
|
||||
expected: [null, null, null, false, true]
|
||||
|
||||
description: |
|
||||
A [**trie**](https://en.wikipedia.org/wiki/Trie) (pronounced as "try") or **prefix tree** is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user