Google Interview Experience ( Trie Question )

Just finished my Google round 1 (virtual) today and thought I’d share. The question was about hierarchical strings (think domains/paths) with values, where each entry contributes to itself + all its ancestors, and we had to compute the total for every leaf.

The neat way to do this is with a Trie (insert reversed parts and then sum while traversing)

But I hadn’t really practiced Tries before 😅. I came up with a tree-based approach instead: reverse parts, sort them, and build a tree by comparing with the previous entry, then do a traversal to get sums.

The interviewer got the idea, but with ~10 mins left I was asked to code and only managed the tree-building part before time ran out.

Not super hopeful about the feedback (probably leaning no hire or no hire), but I’ve got round 2 tomorrow so I’ll just give it my best.

If you’ve got good Trie resources, please drop them!!!!!!!!!!!

second round exp : https://leetcode.com/discuss/post/7102706/google-interview-experience-median-range-bdso/

third round exp : https://leetcode.com/discuss/post/7230869/google-interview-experience-by-charizard-5vuc/

Comments (5)