Question: Write a method called splitStack that accepts a stack of integers as a parameter and rearranges its elements so that all the negatives appear on

Write a method called splitStack that accepts a stack of integers as a parameter and rearranges its elements so that all the negatives appear on the bottom of the stack and all the nonnegatives appear on the top. If after this method is called you were to pop numbers off the stack, you would first get all the nonnegative numbers and then get all the negative numbers. It does not matter what order the numbers appear in as long as all the negatives appear lower in the stack than all the nonnegatives. For example, if the stack stores [3, -5, 1, 2, -4], an acceptable result from your method would be [-5 -4, 3, 1, 2]. Use a single queue as auxiliary storage
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
