SanketAndStrings

what am I doing wrong here?

@abhi18sinha
refer to this here

This has a different approach. Can you please explain where am I going wrong?

@abhi18sinha
for test case
2
abbbababbaba

answer should be 8 not 6

Exactly. So what am I doing wrong?

your code doesn’t find the largest possible answer . Go for the two pointer approach