Sanket and string testcases

could pass only 1 test case with this. please help.

Hey
consider
1
abbababba
Answer should be 4 in this case
But as per your code it is showing 6
Could you dry run for this test case and make required changes?