赞
踩
题目:
题解:
- 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;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。