Question: Write a called SplitStack.java. Write a method splitStack that takes a stack of integers as a parameter and splits it into negatives and non -
Write a called SplitStack.java.
Write a method splitStack that takes a stack of integers as a parameter and splits it into negatives and nonnegatives. The numbers in the stack should be rearranged so that all the negatives appear on the bottom of the stack and all the nonnegatives appear on the top. In other words, 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. You may use a single queue as auxiliary storage.
Write a main method to test SplitStack by passing following examples.
output must be like
output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
