Skip to content

Instantly share code, notes, and snippets.

@ichaos
Created June 9, 2013 07:08
Show Gist options
  • Save ichaos/5741357 to your computer and use it in GitHub Desktop.
Save ichaos/5741357 to your computer and use it in GitHub Desktop.
Algorithm

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment