...

/

Solution Review: Buy and Sell Stock

Solution Review: Buy and Sell Stock

This lesson contains the solution review for the challenge of finding the maximum profit generated by buying and selling stocks!

In this lesson, we will review the solution to the problem in the last exercise. Let’s go over the problem statement once again:

Given an array of numbers consisting of daily stock prices, calculate the maximum amount of profit that can be made from buying on one day and selling on another day.

We consider two approaches to this problem. In the first, we consider a brute force approach that solves the problem in O(N2)O(N^2) ...

Access this course and 1400+ top-rated courses and projects.