🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Union-find
  2. B.Trie
  3. C.Monotonic stack
  4. 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 →