题目描述:

解析:dp
class Solution {public int maxProfit(int[] prices) {int maxProfit=0;int minPrice=Integer.MAX_VALUE;for (int price : prices) {minPrice=Math.min(minPrice,price);maxProfit=Math.max(maxProfit,price-minPrice);}return maxProfit;}}
让时间为你证明