avatar
欢乐颂一点都不欢乐# TVChinese - 中文电视
z*g
1
有N个线段在一条直线上, 已知它们的起点和终点, 求覆盖的总长度。 线段可以有
overlap
Thanks.
avatar
a*3
3
说起来,欢乐颂本来是一种近似与爱情公寓这样的轻喜剧。在第一季的过程中,还有点
这种感觉,但是,到了第二季感觉太沉闷了。每个人的感情和事业都是一团乱。
基本上没有一个省心的,有很多观众是边骂边看剧情。很多观众其实已经失去了兴趣,
对于这部电视的走势。大部分人还是出于对一部中很多的疑问想要找到答案而已。
五美每一个都是很烦恼,不仅仅是五美本人,也包含五美的家人。安迪有间歇精神病,
他母亲也有病,他还有个父亲,父亲还找了后母,后母也是一堆问题,都犯法了被逮捕
了。樊胜美日子过的太凄惨,他父母日子也好不到哪里去,一家人像吸血鬼搭着她,再
加上一个不听话经常闹事的哥哥嫂嫂。曲筱绡家庭人情味太淡,也太复杂,还是多种组
合家庭,她也不被奶奶承认。另外两个倒是家庭不算复杂,可是感情情商太低,就是一
个悲剧的存在。
avatar
r*r
4
sort by the starting point
then traverse from the first segment to the last one

【在 z**********g 的大作中提到】
: 有N个线段在一条直线上, 已知它们的起点和终点, 求覆盖的总长度。 线段可以有
: overlap
: Thanks.

avatar
R*U
5
反了

【在 b*****e 的大作中提到】
: 俺的理解是,通涨要来了,所以大家在疯抢能通涨保值的TIPS债券?
: U.S. sells debt with a negative yield for 1st time
: http://www.reuters.com/article/idUSN2527792620101025

avatar
g*e
6
perhaps can use divede and conquer
not sure exactly
avatar
b*e
7
华尔街日报
http://online.wsj.com/article/BT-CO-20101025-711679.html
The government sold $10 billion in previously sold five-year TIPS for
negative 0.55% yield after selling them at a 0.550% yield when they were
originally sold in April. Because the market expects inflation will be
positive over the next five years though, the expected return for the five-
year TIPS is still positive.

【在 R***U 的大作中提到】
: 反了
avatar
D*d
8
所有线段按起点排序
判断第一段和第二段是否重叠, 重叠就合并, 作为新的第一段, 继续
不重叠就单独拿出来, 以原来的第二段作为第一段, 继续
直到所有线段用完
觉得ARRAYLIST可能用起来比较方便
avatar
R*U
9
WSJ editor sucks, TIPS yields have been negative for quite some time.
It is about "this aucation" more than anything else.
They just try to grab eye-ball.

【在 b*****e 的大作中提到】
: 华尔街日报
: http://online.wsj.com/article/BT-CO-20101025-711679.html
: The government sold $10 billion in previously sold five-year TIPS for
: negative 0.55% yield after selling them at a 0.550% yield when they were
: originally sold in April. Because the market expects inflation will be
: positive over the next five years though, the expected return for the five-
: year TIPS is still positive.

avatar
b*e
10
不用。直接搞一个stack,起点就push,终点就pop,栈不空就加一段,栈空就skip。扫
一遍就可以。
说是栈,其实就是一个整数。判0即可。

【在 D*****d 的大作中提到】
: 所有线段按起点排序
: 判断第一段和第二段是否重叠, 重叠就合并, 作为新的第一段, 继续
: 不重叠就单独拿出来, 以原来的第二段作为第一段, 继续
: 直到所有线段用完
: 觉得ARRAYLIST可能用起来比较方便

avatar
a*6
11
A MONEY CHEATING WORLD

【在 b*****e 的大作中提到】
: 俺的理解是,通涨要来了,所以大家在疯抢能通涨保值的TIPS债券?
: U.S. sells debt with a negative yield for 1st time
: http://www.reuters.com/article/idUSN2527792620101025

avatar
r*r
12
能说再详细一点吗,什么叫起点push终点pop啊...

【在 b***e 的大作中提到】
: 不用。直接搞一个stack,起点就push,终点就pop,栈不空就加一段,栈空就skip。扫
: 一遍就可以。
: 说是栈,其实就是一个整数。判0即可。

avatar
b*e
13
// didn't test, but this is what it is:
// list is sorted.
covered = 0;
stack = 1;
for (i = 1; i < list.length; i++) {
if (stack > 0) {
covered += list[i] - list[i-1];
}
if (list[i] is a starting point) {
stack++;
} else { // if list[i] is an ending point
stack--;
}
}
avatar
s*y
14
Could this solution resolve the overlap scenario?

【在 b***e 的大作中提到】
: // didn't test, but this is what it is:
: // list is sorted.
: covered = 0;
: stack = 1;
: for (i = 1; i < list.length; i++) {
: if (stack > 0) {
: covered += list[i] - list[i-1];
: }
: if (list[i] is a starting point) {
: stack++;

avatar
b*e
15
ya, I guess...

【在 s*****y 的大作中提到】
: Could this solution resolve the overlap scenario?
avatar
s*y
16
your list[i] and list[i-1] is already sorted base on the input or not?

【在 b***e 的大作中提到】
: ya, I guess...
avatar
b*8
17
貌似可以简化一下,第一个左端点入Stack,记下坐标;当某个右端点来了造成Stack空
了,那么此右端点减去前面那个坐标,就是此条合起来大线段的长度。
covered = 0;
stack = 0;
for (i = 1; i < list.length; i++) {
//if (stack > 0) {
// covered += list[i] - list[i-1];
//}
if (list[i] is a starting point) {
if (stack == 0) left = list[i];
stack++;
} else { // if list[i] is an ending point
stack--;
if (stack == 0) covered += list[i] - left;
}
}

【在 b***e 的大作中提到】
: // didn't test, but this is what it is:
: // list is sorted.
: covered = 0;
: stack = 1;
: for (i = 1; i < list.length; i++) {
: if (stack > 0) {
: covered += list[i] - list[i-1];
: }
: if (list[i] is a starting point) {
: stack++;

avatar
h*d
18
不好意思,我大概没理解,如果都在一条直线上,为啥不能keep updating left 和
right, 这样traverse一遍不就有最左和最右了,然后相减得到长度

【在 z**********g 的大作中提到】
: 有N个线段在一条直线上, 已知它们的起点和终点, 求覆盖的总长度。 线段可以有
: overlap
: Thanks.

avatar
b*8
19
There are empty intervals. May not be covered totally.

【在 h**********d 的大作中提到】
: 不好意思,我大概没理解,如果都在一条直线上,为啥不能keep updating left 和
: right, 这样traverse一遍不就有最左和最右了,然后相减得到长度

avatar
h*d
20
got it

【在 b*******8 的大作中提到】
: There are empty intervals. May not be covered totally.
avatar
r*r
21
I guess he already sorted the points

【在 s*****y 的大作中提到】
: your list[i] and list[i-1] is already sorted base on the input or not?
avatar
s*y
22
Then it is not O(N) as sotrt take more than that already le.

【在 h**********d 的大作中提到】
: got it
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。