Implement prototype(words: list[str], prefix: str, limit: int) -> list[str] and solve with the same signature. Return at most limit unique input words beginning with prefix, in Python lexicographic order. Matching is exact and case-sensitive. Empty words and prefixes are valid; limit=0 returns []. A negative limit raises ValueError.
Example: (['cold','colder','coal','cold'], 'co', 3) returns ['coal','cold','colder'].
Prototype: filter, deduplicate, and sort. Final: build a trie, follow the prefix, and enumerate in sorted character order until the limit. Include construction cost when explaining performance. Preserve the word list, including on failure.
Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
Loading editor…
No results yet.
Complete the starter code, then run the checks.
Results and errors will appear here.