专栏名称: 每日一道算法题
学习算法是一种信仰,每天都需要坚持!
目录
相关文章推荐
九章算法  ·  「九点热评」亚麻裁去14000名mgr! ·  21 小时前  
算法爱好者  ·  百度:报案了 ·  2 天前  
九章算法  ·  「九点热评」Meta将被裁员工列入黑名单! ·  3 天前  
51好读  ›  专栏  ›  每日一道算法题

720. Longest Word in Dictionary

每日一道算法题  · 公众号  · 算法  · 2017-11-22 20:48

正文

720. Longest Word in Dictionary


Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than one possible answer, return the longest word with the smallest lexicographical order.


If there is no answer, return the empty string.

Example 1:

Input:

words = [“w”,”wo”,”wor”,”worl”, “world”]

Output: “world”

Explanation:

The word “world” can be built one character at a time by “w”, “wo”, “wor”, and “worl”.

Example 2:

Input:

words = [“a”, “banana”, “app”, “appl”, “ap”, “apply”, “apple”]

Output: “apple”

Explanation:







请到「今天看啥」查看全文