【解题思路】
双重循环,向前查找如果有利润大于当前最大利润的,记录下来。
class Solution {
public int maxProfit(int[] prices) {
int len = prices.length;
int max = 0;
for(int i = 1; i < len; i++)
{
for(int j = 0; j < i; j++)
{
if(prices[i] - prices[j] > max)
{
max = prices[i] - prices[j];
}
}
}
return max;
}
}