Roblox interview question

Trie and DFS hard problem