标签:max 股票 ++ div 时机 return price class turn
1、
class Solution { public int maxProfit(int[] prices) { int len = prices.length; if(len<=1){ return 0; } int min = prices[0]; int max = 0; for(int i=1;i<len;++i){ if(prices[i]-min>max){ max = prices[i]-min; } if(prices[i]<min){ min = prices[i]; } } return max; } }
标签:max 股票 ++ div 时机 return price class turn
原文地址:https://www.cnblogs.com/erdanyang/p/11475103.html