public class Solution {
public int maxProfit(int[] prices) {
if (prices == null || prices.length == 0) {
return 0;
}
int low = Integer.MAX_VALUE;
int profits = 0;
for (int i = 0; i < prices.length; i++) {
low = prices[i] < low ? prices[i] : low;
profits = (prices[i] - low) > profits ? (prices[i] - low) : profits;
}
return profits;
}
}Best Time to Buy and Sell Stock
最新推荐文章于 2026-07-02 10:52:43 发布
282

被折叠的 条评论
为什么被折叠?



