Java Collections | Set 6 (Stack)
Submissions: 981   Accuracy:


  Difficulty: Easy   Marks: 2

Java provides an inbuilt object type called Stack. It is a collection that is based on the last in first out (LIFO) principle. On Creation, a stack is empty. Try this problem using Stack. 

Given n elements of a stack , delete the middle element of the stack without using any additional data structure.

Input: First line of input contains a single integer T which denotes the number of test cases. T test cases follows, first line of each test case contains a integer n. Second line consists of n spaced integers. 

Output: Print the elements of the stack after deleting the middle element.


1<= n <=103


1 2 3 4 5

1 4 9 2 6 5

5 4 2 1
5 6 2 4 1 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: S_A
Author: saksham0751

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.