help me

in the ongoing long challenge…from the question CHEFGP
it’s hard to understand the statement - most recent K fruits distributed (including fruits he previously took, but not counting the fruit he just got)…

I commented in the threads in the contest but no one replied…
please anyone just explain the statement …will be very helpful

You should wait a bit, someone should reply. I remember last time my query got answered after about 2 days.

Lets understand through an example aab here value of k for apple is 1 and for banana is 1 as clear by input style 1 1 and also remember that we have two apple and one banana as clear from string aab these data will be required to understand the problem . Now start counting from 1 the chef was going to give an apple to first person so he have to look for recent k fruits before that apple as from problem statement line most recent K fruits distributed which is none as no fruits being distributed before that apple(but not counting the fruit he just got meaning the apple that he was going to give that first person )… so chef is happy with decision as nothing is violated now the time comes of 2nd person he was also going to give him apple the value of k for apple is 1 so chef look for recent 1 fruits that he have given before so he look for fruit given to first person (mentioning that he can not count the fruit that he was going to give the second person as clear by problem statement ) and he found out that the first person was given apple same he was going to give the second person now the condition is violated as all the kth fruits are same as he was going to give that person under consideration so he changed his decision and give him banana instead of apple now come to third person he was going to give him banana and the value of k for banana is 1 so he have to look for recent k fruit i.e. of second person which is as updation banana and it is same as he was willing to give him but also since in his basket there were two apples and one banana so only apple left and which was desired to give as per condition so there is no need of kiwi fruits he gives him apple and all are happy and output comes aba .If it clears your query either mark the answer correct or leave a comment for further explanation.

//