Delete Middle Element of a Stack
Medium

Problem Statement

Given a stack, delete the middle element of the stack without using any additional data structure. If stack size is even assume mid is (size-1)/2

Examples

1Example 1
Input:
{ "stack": [ 1, 2, 3, 4, 5 ] }
Output:
[ 1, 2, 4, 5 ]
2Example 2
Input:
{ "stack": [ 1, 2, 3, 4 ] }
Output:
[ 1, 3, 4 ]
3Example 3
Input:
{ "stack": [ 10, 20, 30, 40, 50, 60 ] }
Output:
[ 10, 20, 40, 50, 60 ]
Loading...

Sign in to Run Code and Submit