← 💻 Coding & Engineering CraftNEXT IN CODING & ENGINEERING CRAFTPrefix Sums and Difference Arrays→
Core
Monotonic Stack and Monotonic Queue
A monotonic stack keeps its elements sorted so the next-greater or next-smaller element falls out in amortized O(n); a monotonic deque does the same for a sliding window maximum. The shared trick is an invariant: before pushing, discard everything that the new element makes useless. Interviews probe these because they turn an obvious O(n^2) scan into a single pass and test whether a candidate can name what the structure never stores.
a free account unlocks the core curriculum tier · no card
RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS
Coding & DSAFind the next greater element for each item in an array using a monotonic stack.→Machine Learning & Data ScienceHow does LightGBM's histogram binning and GOSS make gradient boosting fast, and what do they cost?→Coding & DSAImplement k-means from scratch, including k-means++ initialization and a convergence check.→Coding & DSAImplement a numerically stable softmax and cross-entropy loss from scratch.→Coding & DSAImplement multi-head self-attention from scratch in NumPy, with a causal mask.→ML Infrastructure & GPUsExplain speculative decoding and the other main levers for cutting LLM generation latency.→
COMPANIES THAT ASSUME THIS
