Search⌘ K
AI Features

Challenge: Find All Words Stored in Trie

Explore how to implement a function that extracts all words stored in a trie data structure. Understand how to traverse the trie efficiently to gather complete words, improving your skills in string manipulation and trie operations in JavaScript.

We'll cover the following...

Statement

Given a trie data structure representing a list of words, implement a function that finds and returns all words stored in the trie.

Constraints:

  • 00\leq words.length 103\leq 10^3

  • 1 1\leq words[i].length 102\leq10^2

  • All words[i] consist of lowercase English letters.

Examples

canvasAnimation-image
1 / 3

Try it yourself

Implement your solution in solution.js in the following coding playground.

JavaScript
usercode > solution.js
import {TrieNode} from './TrieNode.js';
import {Trie} from './Trie.js';
function findWords(root) {
let result = [];
// Replace this placeholder return statement with your code
return result;
}
export {
findWords
}
Find All Words Stored in Trie