Giving wrong output for the original case

In the video, the code is giving wrong output initially and after some tries the code is giving correct output for some other cases but not for the original case. Please look into it. The code with original case has been linked below.

@namangarg2000
Provide me testcase for which your code is giving wrong ans. For testcase “abcdefcghijkzyxz” output is 12 ( “defcghijkzyx”) as given by your code.

Oh sorry, my bad. I got confused. Thank You

@namangarg2000
Mark this doubt as resolved. Thanks