Challenge: Total Number of Words in a Trie

If you are given a Trie, can you find the total number of words it contains? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first.

Problem Statement

Implement the totalWords(TrieNode root) function to find the total number of words in a Trie.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.