KCOMPRESS Last TC

Here is link of my solution to KCOMPRESS " CodeChef: Practical coding for everyone ".

I am somewhere stucked with the last test case.

Can someone find the testcase against which my code is not working ?

Try a test case like [4,4,4,3,4,4,4]. The punch line of this test case was, if there are same elements A_i which are not adjacent, but within a difference of k indexes, the B_i assigned to them must be same.

1 Like

Your code fails for test case

5 9

7 2 9 9 8

Expected Output : 2

Your Output : 3

exactly !!!

https://www.codechef.com/viewsolution/19658864
my soln…
Prob is in cases where there are similar numbers in range…

1 Like
if there are same elements Ai not within a difference of k indexes

Isnt this kind of obvious? How does this anyway disprove what I said? I mentioned a case when same elements lie within k indices and your case is completely something else. We need to be on same platform to “disagree” or agree xD

It isn’t obvious. I wasted 2 days due to this. I tried with difference of 2*k earlier. And more test cases failed. Everytime I tried this I had to drop this idea. Finally used k to get AC.