Skip to content

Latest commit

 

History

History
5 lines (3 loc) · 391 Bytes

README.md

File metadata and controls

5 lines (3 loc) · 391 Bytes

This problem was asked by Facebook.

Given an array of numbers representing the stock prices of a company in chronological order and an integer k, return the maximum profit you can make from k buys and sells. You must buy the stock before you can sell it, and you must sell the stock before you can buy it again.

For example, given k = 2 and the array [5, 2, 4, 0, 1], you should return 3.