Problems > One Perfect Trade > Editorial

One Perfect Trade — Solution & Editorial

Back to the Problem

Sweep with the minimum price so far; the best sale at day i is pi − that minimum.

Complexity: O(N)