Maximum of an Array — Solution & Editorial
Scan once keeping the best so far — O(N). Initialize the maximum with the first element (not 0 — all values may be negative).
Scan once keeping the best so far — O(N). Initialize the maximum with the first element (not 0 — all values may be negative).