Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.最简单的方法就是穷举,O(n2)。 1 public class Solution { 2 public in...
转载 2013-09-11 05:16:00
24阅读
2评论
题目Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (...
转载 2015-04-03 19:26:00
49阅读
2评论
121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte
转载 2019-01-05 22:35:00
112阅读
2评论
1.题目Say you have an array for which the ith element is the price of a given
原创 2022-08-01 20:46:15
113阅读
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
转载 2014-06-24 20:13:00
65阅读
2评论
Question : Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.for example: array[] = { 2, 5, 3, 8, 9, 4 } , m.
转载 2013-04-22 17:04:00
90阅读
2评论
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at
转载 2013-09-11 05:27:00
57阅读
2评论
知道是求连续最大子数组后就简单了。可是注意边界条件,假设最大子数组之和<0,那就不要交易了, 返回0.public class Solution { public int maxProfit(int[] prices) { if(prices.length maxsum) ...
转载 2015-03-31 13:25:00
53阅读
2评论
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock/题
原创 2023-07-26 16:42:53
51阅读
Best Time to Buy and Sell Stock   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, b
原创 2023-02-17 09:31:51
28阅读
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
转载 2014-08-31 11:58:00
108阅读
2评论
Question : Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one
转载 2013-04-21 21:12:00
104阅读
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
转载 2015-03-25 14:42:00
79阅读
2评论
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple
转载 2017-08-13 11:42:00
101阅读
2评论
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
转载 2017-05-24 19:53:00
107阅读
2评论
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
转载 2014-11-29 11:55:00
71阅读
2评论
** * https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/ * Say you have an array for which the ith element is the price of a given stock
转载 2017-04-28 08:49:00
328阅读
2评论
题目: 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),
原创 2022-08-01 12:22:08
151阅读
Best Time to Buy and Sell Stock IISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ...
原创 2021-08-07 11:42:39
104阅读
Question 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 c
原创 2023-02-02 14:56:03
116阅读
  • 1
  • 2
  • 3
  • 4
  • 5