贪心法

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