Concepts4
⚙️AlgorithmIntermediate
Double Counting
Double counting is the strategy of counting the same quantity in two different ways to derive an equality or an efficient algorithm.
#double counting#contribution technique#handshake lemma+12
⚙️AlgorithmIntermediate
Contribution Technique
The contribution technique flips perspective: compute how much each element contributes to the total, then sum these contributions.
#contribution technique#monotonic stack#sum of subarray minimums+12
🗂️Data StructureIntermediate
Stack
A stack is a Last-In, First-Out (LIFO) data structure where push, pop, and top operations run in O(1) time.
#stack#lifo#push+12
🗂️Data StructureIntermediate
Monotonic Stack
A monotonic stack is a stack that keeps its elements in increasing or decreasing order to answer range queries in linear time.
#monotonic stack#next greater element#previous smaller element+12