Playing with cards (in stack) problem


I m getting arithmetic exception error. Please help me resolve it.

hello @apoorvas1301
image

for i=0 , i-1 will be -1 and u cannot access -1 index ,it will give error

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.