How to solve this question that appeared on Byte Code 2015

algorithm
c-plus-plus
data-structure
editorial
lca
trie

#1

BTCD1510