Cloze

One passEasy

Best Time to Buy and Sell Stock

Given a price for each day, find the biggest profit from buying on one day and selling on a later one, or 0 if no sale earns anything.

Aim for O(n) time, O(1) spaceInspired by a classic interview problem ↗