title: Maximum single-sell profit
body: <p>Suppose we are given an array of <em>n</em> integers representing stock prices on a single day.  We want to find a pair <em>(buyDay, sellDay)</em>, with <em>buyDay &le; sellDay</em>, such that if we bought the stock on <em>buyDay</em> and sold it on <em>sellDay</em>, we would maximize our profit.</p>
  
  <p>Clearly there is an <em>O(n<sup>2</sup>)</em> solution to the algorithm by trying out all possible <em>(buyDay, sellDay)</em> pairs and taking the best out of all of them.  However, is there a better algorithm, perhaps one that runs in <em>O(n)</em> time?</p>