fix the bug that LSWRC will not work if the longest substring happened at the end of the string