yaminote's blog

By yaminote, history, 2 years ago, In English

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?

  • Vote: I like it
  • -4
  • Vote: I do not like it