Difficulty in coding part

I find it difficult to understand the solution explained in this video. Can you provide the solution of this problem so I can go through it and understand it properly?

hello @abhi_11

pls check this->

First, try to finish it without playing any empty cards.

If that’s not possible, the best choice is to play several empty cards in a row, then play from 11 to n.
For a card i, suppose that it is in the pi-th position in the pile (pi=0 if it is in the hand), you have to play at least pi−i+1 empty cards.
So the answer will be max{pi−i+1+n}

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.