Solving Longest Word in Dictionary in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

If there is no answer, return the empty string.

Example 1:

words = ["w","wo","wor","worl", "world"]
Output: "world"
The word "world" can be built one character at a time by "w", "wo", "wor", and "worl".

Example 2:

words = ["a", "banana", "app", "appl", "ap", "apply", "apple"]
Output: "apple"
Both "apply" and "apple" can be built from other words in the dictionary. However, "apple" is lexicographically smaller than "apply".


  • All the strings in the input will only contain lowercase letters.

See the full details of the problem Longest Word in Dictionary at LeetCode

Originally posted at: