Comments

Thanks got you!

How do you decide N=8191 ? It won't work with any other value.

And you are still unrated after 2 years

You have to create a new temporary array where you store the index of last occurrence of all characters that you have encountered so far and then binary search on that array. if distinct characters(tempArr[mid],i)==(tempArr.size()-mid+1) then move left else you have find a potential character save it into variable (say fans) and move right in tempArray. Finally do ans+=fans;

LINK->160405246

How do you deduce this from query limit that binary search is to be used?

I solved it using binary search on minimum possible answer we could obtain. In check function I checked for the minimum number of operations needed if I try to convert substring of length k into either RGB../GBR../BRG.. using prefix sum technique. If its >=mid it could be my potential answer.

LINK:157491692

Thanks for the help I didn't noticed that.

Can anyone help why is this giving me TLE for D 147473308 ?

Which company's assessment?