mirror of
https://github.com/krahets/hello-algo.git
synced 2026-12-01 19:31:00 +08:00
Reverts #2034, #2035, #2036 and #2037. The work will return in a single
reviewed PR that is completed before it merges. The tree equals 8c96e2f30
(#2033).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b113cb425a
commit
ded7ddc635
@@ -10,43 +10,31 @@ import java.util.*;
|
||||
|
||||
public class stack {
|
||||
public static void main(String[] args) {
|
||||
// [region]{init_stack}
|
||||
/* Initialize the stack */
|
||||
Stack<Integer> stack = new Stack<>();
|
||||
// [endregion]{init_stack}
|
||||
|
||||
// [region]{push}
|
||||
/* Push elements onto the stack */
|
||||
stack.push(1);
|
||||
stack.push(3);
|
||||
stack.push(2);
|
||||
stack.push(5);
|
||||
stack.push(4);
|
||||
// [endregion]{push}
|
||||
System.out.println("Stack stack = " + stack);
|
||||
|
||||
// [region]{peek}
|
||||
/* Access the top element */
|
||||
int peek = stack.peek();
|
||||
// [endregion]{peek}
|
||||
System.out.println("Top element peek = " + peek);
|
||||
|
||||
// [region]{pop}
|
||||
/* Pop an element from the stack */
|
||||
int pop = stack.pop();
|
||||
// [endregion]{pop}
|
||||
System.out.println("Popped element pop = " + pop + ", after popping, stack = " + stack);
|
||||
|
||||
// [region]{size}
|
||||
/* Get the stack size */
|
||||
int size = stack.size();
|
||||
// [endregion]{size}
|
||||
System.out.println("Stack size = " + size);
|
||||
|
||||
// [region]{is_empty}
|
||||
/* Check whether it is empty */
|
||||
boolean isEmpty = stack.isEmpty();
|
||||
// [endregion]{is_empty}
|
||||
System.out.println("Is the stack empty = " + isEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user