WA for problem : STACKS

I am getting WA for problem STACKS and can not figure out the testcase where my code fails. Please help!

Here is the link to my submission: CodeChef: Practical coding for everyone

Instead of writing, stackTops.erase(*greaterItr);
write stackTop.erase(greaterItr);
In a multiset, if you call an erase function with a value suppose x, then it will erase all occurrences of x in the multiset. So, if you want to delete a single occurrence you have to call the erase function with the iterator to that value.
What you are doing is erasing all occurrence of the disk upon which you are placing your current disk.

1 Like

Thanks a lot @mrityuanjaya :smile:

1 Like