Divide and conquer
The maximum subarray problem
Brute-force: just try every possible pair of buy and sell dates in which buy dates precedes the sell dates
then find the maximum. O(n2)
Divide and conquer
Linear method
Divide and conquer
The maximum subarray problem
Brute-force: just try every possible pair of buy and sell dates in which buy dates precedes the sell dates
then find the maximum. O(n2)
Divide and conquer
Linear method