Find all substrings which are repeated
04:11 28 Sep 2022

I need to find all substring of length greater than 2 which are repeated. I can solve it using brute force .Is there any other optimal solution available?

eg . SpringisHereAgainSpringHere
Sample output : Spr,Spri,Spring,here,her
string algorithm data-structures