Here is link of my solution to KCOMPRESS " https://www.codechef.com/viewsolution/19705500 ".
I am somewhere stucked with the last test case.
Can someone find the testcase against which my code is not working ?
Here is link of my solution to KCOMPRESS " https://www.codechef.com/viewsolution/19705500 ".
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.
exactly !!!
https://www.codechef.com/viewsolution/19658864
my soln…
Prob is in cases where there are similar numbers in range…
I disagree with @vijju123 here.
e.g. -
K = 3
A = [1,1,1,8,1,1,1,1,9,1,1,2,3,8,3,2,1]
B = [1,1,1,2,1,1,1,1,3,1,1,2,3,4,3,2,1]
The punch line of this test case was, if there are same elements Ai not within a difference of k indexes, the Bi assigned to them may not be same.
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
Your code fails for test case
5 9
7 2 9 9 8
Expected Output : 2
Your Output : 3
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.