pls anyone can explain the problem i does not properly get the problem pls explain me!!!
Sanket and stringsss
you can change (a to b )or (b to a) maximum k times and return the value of maximum contigous same letters after flipping.
Like abba and k=2
I can change first and fourth character to b and will get maximum 4 length string having same characters i.e. bbbb
Hit like if u get it
sorry bhayia but i donβt get what you say pls help me some how or can i get video tutorial to get the question pls
Hey Ankush, the problem is pretty simple
- you will be given a string consisting of only a and b as the characters.
- you have to find the maximum length of substring made of either character a or b.
- for getting the substring of maximum length of same character you have K no. of chances to change character from (a to b ) or (b to a).
for eg.
input string : abbaaab
K = 2
so here you can change character b to a at indexes 1 and 2 (you can change only 2 characters because K is 2). Now after making the change you will get the string as aaaaaab so the max length substring with same characters is aaaaaa of length 6, therefore the output for the given case is 6.
I hope you will be able to understand the problem now. If still you are facing some problem do reply to this thread, we will definitely help you with some alternative.
i have tried it but giving me wrong output. didi can u check my code pls, https://ide.codingblocks.com/s/55153
Hey Ankush, your approach is not correct, you can take reference from this https://ide.codingblocks.com/s/55197.
didi i still havw doubt as i cannot able to read java code but i have tried my own i get the ans correct but i get run error in each test case here is my code : https://ide.codingblocks.com/s/55438
Hey Ankush, read the constraints mentioned carefully, 2 β€ N β€ 10^5 but you have taken the max size as 100. But still after that also your code will not work for some case. Here I am sharing my code in c++ you can refer this.
didi can yu explain the if condition of your code line no. 16