Count Occurrences
Count specific elements
Track Maximum
Find running max
Find Leaders
Elements > all left
Count Pairs
Count valid pairs
🧠 Memory Update
Click "Step Forward" to start traversing...
💡 Carry Forward Technique
Instead of recalculating everything at each position, we "carry
forward" computed values:
- Count mode: carry += 1 when condition met
- Max mode: carry = max(carry, current)
-
Leaders: if current > carry, it's a leader; update
carry
-
Pairs: count pairs using previously computed counts