Solved a longest non complete substring problem