← Quiz: Monotonic Stack: all 13 questions
Quiz: Monotonic Stack · Question 8 of 13
In Java, which type is recommended for a stack?
In Java, which type is recommended for a stack?
- A.java.util.Stack
- B.ArrayDeque (used through the Deque interface)
- C.LinkedList only
- D.int[] with no counter
Answer & explanation
Correct answer: ArrayDeque (used through the Deque interface)
Stack is an old synchronised class; ArrayDeque is faster and is the recommended stack and queue.
Can you get the rest right without peeking?
Take the timed Quiz: Monotonic Stack quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →