We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The problem is correct. If you start with one stack and keep dividing by P∈Q. After each division, you are left with either 1 stack (in case all the elements in the stack are either divisible by P or all the elements are not divisible by P), or 2 (in case some elements are divisible and some other are not).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Waiter
You are viewing a single comment's thread. Return to all comments →
The problem is correct. If you start with one stack and keep dividing by P∈Q. After each division, you are left with either 1 stack (in case all the elements in the stack are either divisible by P or all the elements are not divisible by P), or 2 (in case some elements are divisible and some other are not).