Redian新闻
>
买了房子后,给buyer broker and loan broker礼物卡么?
avatar
买了房子后,给buyer broker and loan broker礼物卡么?# Living
a*e
1
别人的答案,但不太清楚怎么能证明或者保证两个区间没有相交?我开始是想照CC150
上说的那样把所有可能的情况列出来找规律,但到后面越想就越糊涂了。多谢!
比如
1235
12305
10325
1032502
‘You may not engage in multiple transactions at the same time (ie, you must
sell the stock before you buy again).’
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 complete at most two
transactions.
Note:
You may not engage in multiple transactions at the same time (ie, you must
sell the stock before you buy again).
// LeetCode, Best Time to Buy and Sell Stock III
// 时间复杂度O(n),空间复杂度O(n)
class Solution {
public:
int maxProfit(vector& prices) {
if (prices.size() < 2) return 0;
const int n = prices.size();
vector f(n, 0);
vector g(n, 0);
for (int i = 1, valley = prices[0]; i < n; ++i) {
valley = min(valley, prices[i]);
f[i] = max(f[i - 1], prices[i] - valley);
}
for (int i = n - 2, peak = prices[n - 1]; i >= 0; --i) {
peak = max(peak, prices[i]);
g[i] = max(g[i], peak - prices[i]);
}
int max_profit = 0;
for (int i = 0; i < n; ++i)
max_profit = max(max_profit, f[i] + g[i]);
return max_profit;
}
};
avatar
d*t
2
buyer broker花了很多功夫时间,觉得应该表示一下。
Loan broker, 就是邮件电话来往,没见面,需要给礼物卡么?
avatar
d*t
3
绿皮书原题,kadanes algo

CC150
must

【在 a***e 的大作中提到】
: 别人的答案,但不太清楚怎么能证明或者保证两个区间没有相交?我开始是想照CC150
: 上说的那样把所有可能的情况列出来找规律,但到后面越想就越糊涂了。多谢!
: 比如
: 1235
: 12305
: 10325
: 1032502
: ‘You may not engage in multiple transactions at the same time (ie, you must
: sell the stock before you buy again).’
: Say you have an array for which the ith element is the price of a given

avatar
m*j
4
像吃饭一样,付15%的小费?

【在 d******t 的大作中提到】
: buyer broker花了很多功夫时间,觉得应该表示一下。
: Loan broker, 就是邮件电话来往,没见面,需要给礼物卡么?

avatar
a*e
5
请问绿皮书是哪本书啊?多谢
avatar
y*f
6
送礼送习惯了?

【在 d******t 的大作中提到】
: buyer broker花了很多功夫时间,觉得应该表示一下。
: Loan broker, 就是邮件电话来往,没见面,需要给礼物卡么?

avatar
g*9
7
我是这样子想的 要是有交集的话 那只需要交易一次就可以了,题目说的是最多可以交
易两次。比如 你用DP的算法算出来 第一天买进 第五天卖出 第五天买入 第十天卖出
的时候profit最多 这样子的话 其实可以看做第一天买进 第十天卖出 只交易一次就行
了 不知道这样子回答你了没有

CC150
must

【在 a***e 的大作中提到】
: 别人的答案,但不太清楚怎么能证明或者保证两个区间没有相交?我开始是想照CC150
: 上说的那样把所有可能的情况列出来找规律,但到后面越想就越糊涂了。多谢!
: 比如
: 1235
: 12305
: 10325
: 1032502
: ‘You may not engage in multiple transactions at the same time (ie, you must
: sell the stock before you buy again).’
: Say you have an array for which the ith element is the price of a given

avatar
w*m
8
没给我送HOUSE WARMING GIFT,还给他们送?疯啦
avatar
h*5
9
有钱没处花?
avatar
h*z
10
反了,应该他们给你送,他们拿了那么多钱。。。。
如果你有钱,版上的有帮助的 ID可以给点GC :-)
http://www.amazon.com/exec/obidos/ASIN/BT00CTP2GM/1-b003homep2-
或者包子:—)

【在 d******t 的大作中提到】
: buyer broker花了很多功夫时间,觉得应该表示一下。
: Loan broker, 就是邮件电话来往,没见面,需要给礼物卡么?

avatar
w*m
11
对啊,给我几个包子,安慰一下我受伤的心灵
avatar
d*t
12
好吧,看来木这个必要。谢谢大家乐。
俺也是需要省者过。
包子不会发,还没学呢。不过着实谢谢回复。

【在 h***z 的大作中提到】
: 反了,应该他们给你送,他们拿了那么多钱。。。。
: 如果你有钱,版上的有帮助的 ID可以给点GC :-)
: http://www.amazon.com/exec/obidos/ASIN/BT00CTP2GM/1-b003homep2-
: 或者包子:—)

avatar
c*7
13
They will be paid by your commission.They should treat you a dinner for your
payment.
avatar
s*3
14
喜欢的话给个testimony,比礼物卡好
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。