Sanket and strings wrong answer in some testcases

my approach is linearily traversing the string ,if character mismatches then decrement the k(allowed changes). If i exhaust k then retrace from where i have started using k

@piyush.bansal8158625
Share your code using ide.codingblocks.com please,

@piyush.bansal8158625
Here are some of the testcases your code fails
Input :
2
abbaabbaaaa

Expected Output :
8

Your Output :
7


Input :
0
bbbaabbaaaa

Expected Output :
4

Your Output :
( No Output - Goes into infinite loop)


Input :
1
abbab

Expected Output :
4

Your Output :
( No Output - Goes into infinite loop)