I recetly come across an interview question : To find all the repeating substring in a given string with a minimal size of 2. The algorithm should be efficient one.
Cod
I don't know how suffix tree can get all the repeating substring, string "mississippi" build suffix tree like this:
sorry,I see. "At the end, iterate over each node with count>1 and print its path." "count" is how many this child node
tree-->|---mississippi m..mississippi
|
|---i-->|---ssi-->|---ssippi i .. ississippi
| | |
| | |---ppi issip,issipp,issippi
| |
| |---ppi ip, ipp, ippi
|
|---s-->|---si-->|---ssippi s .. ssissippi
| | |
| | |---ppi ssip, ssipp, ssippi
| |
| |---i-->|---ssippi si .. sissippi
| |
| |---ppi sip, sipp, sippi
|
|---p-->|---pi p, pp, ppi
|
|---i p, pi
--- Suffix Tree for "mississippi" ---