Taro Logo
1

What resources have people found helpful when first learning monotonic stacks and queues?

Profile picture
Mid-Level Software Engineer at Vanderbilt University Medical Center18 days ago

I found monotonic stacks and queues to be quite difficult at first, but I felt like it would be worth the effort to become more familiar with them (seems like it would be virtually impossible to come up with them in the context of a DSA interview). My efforts led to me writing an introductory post about the monotonic stack/deque data structure.

The post linked above is all text-based, but I realize others sometime learn more effectively through other mediums (e.g., video-based instruction). Curious to know what other resources people have found to be of use!

49
2

Discussion

(2 comments)
  • 0
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero
    16 days ago

    I'm going to be honest: I don't know what monotonic stacks and queues are (maybe I've encountered them before but didn't realize this terminology was the right way to refer to them).

    My advice here (and in general) is to learn by doing. If you encounter a LeetCode problem and the answer involves a monotonic stack/queue, you will definitely learn the concept, especially if this is from a live interview. Optimistically consuming resources is a hard way to learn as retention is low.

    For stacks and queues and data structures/algorithms overall, I'm a big fan of visualization. So things like diagrams, especially if they're animated, are great. NeetCode is great at this, and you get a discount on it if you're a Taro Premium member: https://www.jointaro.com/perks/

  • 1
    Profile picture
    Staff Eng @ Google, Ex-Meta SWE, Ex-Amazon SDM/SDE
    16 days ago

    So a priority queue that trims everything of lesser priority on insert (lesser would be based on directionality)? But you normally use it for indexes into something else?

    This is probably really important for certain things. It is not a type of problem I’ve needed to solve, but that certainly doesn’t mean it isn’t valuable.

    I consider myself… I don’t know, pretty good at understanding things… I don’t know if this subject is over my head, or if your writeup is assuming things about the reader, but even having eventually worked out how the structures work, I still don’t really understand how it solves these problems.

    It’s admirable to have written this up, and I’m confident there is an audience for this, and I don’t think I’m part of it.