Airbnb interview question

Trie question, part one was easy, second was leetcode hard