Codechef C.O.D.E.R.S Solution

Revision en1, by yaminote, 2021-11-29 20:48:23

I am getting WA on three of the test cases on following solution- https://www.codechef.com/viewsolution/54539476 My logic

If K is 0 and all indices are same then print N else -1; Now moving to when K>0 I check for each letter using a loop seeing what would be the answer if the given letter were remaining, I find the number of consecutive set of gaps in between the given letters. Now If gaps are less than or equal to K then the answer is the number of letters itself. Otherwise we are supposed to remove any of the (gaps-(k-1)) consecutive gaps and see how many of the given letter are removed in the process. Anything wrong with the approach?

Tags codechef, help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English yaminote 2021-11-29 20:48:23 696 Initial revision (published)