买卖股票的最佳时机

public class Solution {
/**
* @param prices: Given an integer array
* @return: Maximum profit
*/
public int maxProfit(int[] prices) {
// write your code here
int Max = 0;
if( prices == null || prices.length == 0)
return 0;

for(int i = 0;i< prices.length ;i++){
for(int j = i;j< prices.length ;j++)
Max = Math.max(Max, prices[j] - prices[i]);
}
return Max;
}
}

原文地址:https://www.cnblogs.com/yiwenhao/p/6523517.html