Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), d
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 思路。只需要前一天比后一天小就可以前一天卖出,买进,后一天再卖出,计算 public static int maxProfit1(int[] prices) {int sum = 0;for(int i=1;i<prices.
题目要求: 121. Best Time to Buy and Sell Stock QuestionEditorial Solution My Submissions Total Accepted: 139457Total Submissions: 364702Difficulty: EasyContributors: AdminSay you have an array for w