import java.util.*; public class Solution { /** * * @param prices int整型一维数组 * @return int整型 */ public int maxProfit (int[] prices) { int min = 10000; int res = 0; for (int i = 0; i < prices.length; i++) { res = Math.max(prices[i] - min, res); min = Math.min(min, prices[i]); } return res; } }