Maximal Range That Each Element Is Maximum in It
Two monotonic-stack passes find the nearest strictly greater value on each side; the gap between them is the range.
Two monotonic-stack passes find the nearest strictly greater value on each side; the gap between them is the range.