This question appeared in a contest on hacerrank.
Any ideas on how to solve this tree problem efficiently? I got only 57.14 points with my binary search and preorder-pattern matching approach.
I'm asking for your help and approach because no submissions are available to see.
SecondThread orz Errichto please help with this. I know red coders are busy and shouldn't tag them, but I need help and this problem seems tough. If you think it's too easy, just tag someone else (like yellow maybe).
Here's what I've tried:
Even I've solved the O(n^2 log N) thing using binary search.
I also tried serializing the tree and using suffix automaton to solve the longest duplicate substring on it, but seems like it won't work.
In these moments, I'm sorry that I'm red.