The question never stated that we can pick almost one element from each partition which created so much confusion and time wastage. Because simply for the test case 5 -1 3 can give you sum as 7 and also no two consecutive integers are from same blocks, why is this not a valid pattern for generating subsequence?
Incomlete question maybe?
Hey @ayushjain.iitg
For 5, -1 and 3, difference between indices of 5 and -1 is k(viz 5).
As said in the question:
the indexes of any two integers of this subsequence be i and j, then he wants |i−j| != K.
@ayushjain.iitg
The given array will have two blocks, first five elements will be in the first block, and the last element would be in the second block, and according to the question, you can choose at max one element from each block, so 4, 3, -1 can’t be chosen because 4 and 3 are in the same block.
@ayushjain.iitg
basically you’ve to make ceil(n/k) sized blocks of size k in the question(in this example ceil(6/5) i.e. 2 blocks of size 5), so first block will be of size k(viz 5) and for the last block only one element remains.
In any example you consider the last block may have less than k elements
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.