← Back to Games

Right-Side Guardian

Move from RIGHT to LEFT, building the suffix maximum array!

Traversing RIGHT to LEFT
Current Index
-
Current Value
-
Suffix Max (Right Max)
-
Original Array
Suffix Max Array (Right Max)
🎯 Why Suffix Max Matters

Trapping Rainwater

Combined with Prefix Max (Left Max), suffix max helps calculate water trapped at each position.

water[i] = min(leftMax[i], rightMax[i]) - height[i]

Stock Problems

Find the maximum selling price available after each day to calculate best profit.

profit = maxRight[i] - price[i]