Wednesday, September 26, 2018

720. Longest Word in Dictionary (I)

Sept. 26, 2018

Introduction


It is an easy level algorithm. But I did think about Trie for a few times in my first 20 minutes brainstorm to find all ideas. Here are things I thought about.

1. Sort the words by length
2. Check word by word by length, starting from length = 1, maximum length is 30
3. Use Trie data structure

It is definitely a good algorithm to work on. I like to get some experience from all the sharing first.

My practice


Here is my practice using hashset only. It is easy and quick solution.

9/26/2018
Here is my practice using Queue.
Here is my practice using recursive function.

No comments:

Post a Comment