请教一道关于unique substrings的题

This is kind of like File System problem in 第七课:Airbnb 专题之OOD

One way is to use Map and the other way is Trie. There is tradeoff.