Im not able to get the logic of the question
Playing with cards(in stack) Stacks and Queues
This question is actually quite simple. Just store the first 10^6 primes in an array using Sieve of Eratosthenes. Now, you just have to proceed the way it is given in the question i.e. simulate the entire process by either creating n (worst case no of stacks required is n ) stacks beforehand or create them dynamically as the condition arisis for creating them.
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.