← Quiz: Approaching DSA Interview Problems: all 10 questions
Quiz: Approaching DSA Interview Problems · Question 6 of 10
A problem asks for the next greater element for each item. Which pattern fits best?
A problem asks for the next greater element for each item. Which pattern fits best?
- A.Union-find
- B.Trie
- C.Monotonic stack
- D.Dijkstra
Answer & explanation
Correct answer: Monotonic stack
A stack of items still waiting for a bigger value gives an O(n) solution.
Can you get the rest right without peeking?
Take the timed Quiz: Approaching DSA Interview Problems quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →