Playing with cards (stack)

My code is passing only one test case.Please tell me whats with it.

You are dividing by primes[i] to check if it is divisble by ith prime number which is wrong. Your primes array stores whether the ith number is prime or not and NOT the ith prime number.

Sir,I believe the primes array is storing the ith prime number itself and not if the number is prime or not. The array p there stores if the number is prime or not

I am so sorry I missed that. Btw I think you have misunderstood the question. For the ith iteration, you are not popping out elements from bth stack, instead you are again and again iterating over the input array.

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.