![]() |
VOOZH | about |
Given a set of words represented in a ternary search tree, find the length of largest word among them.
Examples:
Input : {"Prakriti", "Raghav",
"Rashi", "Sunidhi"}
Output : Length of largest word in
ternary search tree is: 8
Input : {"Boats", "Boat", "But", "Best"}
Output : Length of largest word in
ternary search tree is: 5
Prerequisite : Ternary Search Tree
The idea is to recursively search the max of left subtree, right subtree and equal tree.
If the current character is same as the root's character increment with 1.
Implementation:
Length of largest word in ternary search tree is: 8