/**
  * 
  * @param prices int整型一维数组 
  * @return int整型
  */
function maxProfit( prices ) {
    // write code here
    let n = prices.length
    let sell = 0
    let buy = -prices[0]
    for(let i=0;i<n;i++){
        sell = Math.max(sell,buy+prices[i])
        buy = Math.max(buy,-prices[i])
    }
    return sell
}
module.exports = {
    maxProfit : maxProfit
};