贪心呜呜呜
感觉不难 但是想不到
class Solution {
public int maxProfit(int[] prices) {
int ans = 0;
int n = prices.length;
for(int i = 1; i < n; i ++){
ans += Math.max(0, prices[i] - prices[i - 1]);
}
return ans;
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)