![]() |
VOOZH | about |
Given a stack s, remove the middle element of it without using any additional data structure.
Input: s = [10, 20, 30, 40, 50]
Output: s = [10, 20, 40, 50]
Explanation: After deleting the mid which is 30, stack will look like [10, 20, 40, 50].Input: s = [1, 2, 3, 4]
Output: s = [1, 3, 4]
Explanation: The stack has 10 elements (even), there are two mid elements 2 and 3, we delete the first of the two.
Note : The output printed by the following codes is reverse of the order as we pop the top elements one by one and print.
Table of Content
50 40 20 10
50 40 20 10
50 40 20 10