Increasing Array — Solution & Editorial
Sweep with the running required minimum: every element below it must be raised exactly to it; every element above raises the bar.
Complexity: O(N)
Watch out: The total reaches ~1014 — 64-bit.
Sweep with the running required minimum: every element below it must be raised exactly to it; every element above raises the bar.
Complexity: O(N)
Watch out: The total reaches ~1014 — 64-bit.