Number of People That Can Be Seen in a Grid
Sweep every row and column with a monotonic stack; each person counts the taller-or-equal wall that stops the view.
Sweep every row and column with a monotonic stack; each person counts the taller-or-equal wall that stops the view.