3 ms·The right algorithm for this problem starts with a linear time suffix sort.by cperciva 2y agoThe right algorithm for this problem starts with a linear time suffix sort.