Which case I am failing ??
Sanket and String
You are not considering substring starting from index other than 0.
You should consider all the cases.
eg-s=“abbbbbba” , k = 2
Your code will give 3 as answer while correct answer is 8
You can use two pointer here and trying making longest possible substring for both ‘a’ and ‘b’.