Prototype: implement prototype(List<String> words, String prefix, int limit) returning List<String> with a direct baseline.

Final: implement solve(List<String> words, String prefix, int limit) with the mechanism and bounds described above. Return at most limit distinct words starting with the exact case-sensitive prefix, in Java String.compareTo order. Empty strings/prefixes are valid, limit zero returns empty, negative limit raises IllegalArgumentException. Final must build a trie; prototype may filter/deduplicate/sort. Both stages have the same observable contract. The prototype may use the simpler method; final must use the target data structure.

All methods are static members of Exercise.

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…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.