Restore Sequence codechef november long challenge problem solution -
Restore Sequence codechef november long challenge problem solution lets read problem statement.
2 5 5 2 3 4 5 4 4 4 4 4
2 6 5 3 4 2 6 3 12
Restore Sequence codechef Solution -
It's necessary that b[i]>=i
let's assume my final ans is 2*n,2n-1,2n-2,2n-3...........n+1
I choose this initial sequence because ith element of this sequence cannot divide any other incoming element of this sequence.
store this sequence into a final answer vector
Now you have to change this sequence in such a way it can produce given B.
Now start iterating given array B.
Now change final ans like this
Finally, print ans vector.
Follow the code below.
This question can be done by another approach.
Must Join Telegram channel for Editorial -