Redian新闻
>
古龙的小说大多是悲剧,金庸的小说大多是喜剧
avatar
古龙的小说大多是悲剧,金庸的小说大多是喜剧# paladin - 谈古论金,黄梁一梦
s*r
1
一个很小的公司, 要我一个小时写个程序发过去, 用了一个很simple的算法,就是从给
定range的每个integer对比一个range一个range的看, 大家看看这题如果要efficient
怎么弄?
Write a function that takes a list of integer ranges and an additional range
and prints all non-overlapping ranges from the additional range.
For example, given a list or ranges [6 – 10], [17 – 24], [15 – 19] and a
new range [8 – 28], your function should print [11 – 14], [25 - 28].
avatar
w*e
2
上个月还在打橄榄球拿了超级碗,这个月又拿了奥斯卡,啧啧
avatar
s*r
3
古龙的小说跟金庸比起来整体的调调都太悲了吧,几乎没有一个是大团圆的结局啊,都
是这么悲惨,金庸的则大部分结局是喜剧,该在一起的都在一起了,坏人都死了,好人
都有主角光环,这是不是也是金庸的小说更受欢迎的原因之一呢,毕竟观众还是喜欢喜
剧的偏多啊,谁没事儿愿意被悲剧虐心呢。
我看古龙的《圆月弯刀》的时候,真的被虐到了极点,还是大帅哥古天乐主演的,自己
心爱的女人居然还是死在自己的手里了,简直是痛不欲生啊,一路剧情发展的也是虐心
不停,看完《圆月弯刀》以后,我很少再看古龙小说拍的电视剧了,我这小心脏禁不住
这么虐啊。看看人家金庸,这好几部戏拍下来,大家看的多欢乐多解气。观众们看电视
剧还是追求娱乐的,谁也不愿意看了半天心里这个难受啊。《萧十一郎》也是个虐心的
,《楚留香传奇》更虐心,那么多美女,结果最想在一起的都没在一起。
我甚至怀疑,古龙活的时间短,是不是跟他写的小说都是悲剧有关系,看看同样是写了
那么多部武侠小说的金庸,怎么能活这么大岁数呢?《天涯明月刀》和《多情剑客无情
剑》也都是悲剧结尾,爱情都不圆满,主角的遭遇也都是坎坷的让人揪心。要想看完了
开心点,还就得是看金庸的作品了。
avatar
c*n
4
根据第一个数排序,然后一个个range往后比对,维护一个global right bound,
每次都把这个right bound和rang的left value比较就好了吧?

efficient
range
a

【在 s*****r 的大作中提到】
: 一个很小的公司, 要我一个小时写个程序发过去, 用了一个很simple的算法,就是从给
: 定range的每个integer对比一个range一个range的看, 大家看看这题如果要efficient
: 怎么弄?
: Write a function that takes a list of integer ranges and an additional range
: and prints all non-overlapping ranges from the additional range.
: For example, given a list or ranges [6 – 10], [17 – 24], [15 – 19] and a
: new range [8 – 28], your function should print [11 – 14], [25 - 28].

avatar
H*7
5
还是飞人
avatar
p*a
6
致老邢
为啥机器人分段还是像机器人呢?
我估计是分完段,没有再空一行的缘故
老邢注意改进一下
一般来说一个意思就分一段了,看看菌斑板友嘛!
avatar
m*9
7
我的思路是这样的
1. 把new range [8,28] dump到数组A中,使得A[index] = index, 如果没有出现的
value,则设置为-1,即:
分配一个size=29的数组,[8,28]dump到该数组的结果就是:
A[-1,-1,-1,...-1,8,9,10,11,.....28]
2. 一次遍历list of ranges, 凡是能够在A中能够找到的value全部都设定为A[index]=
-1.
例如:对比[6,10]时, A[6]=-1, A[7]=-1; ... A[10]=-1
这样把整个range都遍历完
3. 再次遍历数组A,将A[index]!=-1的全部打印出来
avatar
v*t
8
都是药物产品

【在 H******7 的大作中提到】
: 还是飞人
avatar
d*2
9
行与行之间留白空的都是wsn,
写paper留下来的习惯

【在 p********a 的大作中提到】
: 致老邢
: 为啥机器人分段还是像机器人呢?
: 我估计是分完段,没有再空一行的缘故
: 老邢注意改进一下
: 一般来说一个意思就分一段了,看看菌斑板友嘛!

avatar
c*n
10
en这个时间上更快

]=

【在 m******9 的大作中提到】
: 我的思路是这样的
: 1. 把new range [8,28] dump到数组A中,使得A[index] = index, 如果没有出现的
: value,则设置为-1,即:
: 分配一个size=29的数组,[8,28]dump到该数组的结果就是:
: A[-1,-1,-1,...-1,8,9,10,11,.....28]
: 2. 一次遍历list of ranges, 凡是能够在A中能够找到的value全部都设定为A[index]=
: -1.
: 例如:对比[6,10]时, A[6]=-1, A[7]=-1; ... A[10]=-1
: 这样把整个range都遍历完
: 3. 再次遍历数组A,将A[index]!=-1的全部打印出来

avatar
i*r
11
人家田径也很牛的,奥运会拿好几个金牌

【在 w******e 的大作中提到】
: 上个月还在打橄榄球拿了超级碗,这个月又拿了奥斯卡,啧啧
avatar
s*r
12
这样还是要一个个遍历所有的range, 有没有不需要一个个range遍历的.
另外, 最开始的数组都没有用, 直接for loop 从begin开始到end, 一个个查是否在
range就行了.

]=

【在 m******9 的大作中提到】
: 我的思路是这样的
: 1. 把new range [8,28] dump到数组A中,使得A[index] = index, 如果没有出现的
: value,则设置为-1,即:
: 分配一个size=29的数组,[8,28]dump到该数组的结果就是:
: A[-1,-1,-1,...-1,8,9,10,11,.....28]
: 2. 一次遍历list of ranges, 凡是能够在A中能够找到的value全部都设定为A[index]=
: -1.
: 例如:对比[6,10]时, A[6]=-1, A[7]=-1; ... A[10]=-1
: 这样把整个range都遍历完
: 3. 再次遍历数组A,将A[index]!=-1的全部打印出来

avatar
i*r
13
有段时间还做过我们系里小秘

【在 w******e 的大作中提到】
: 上个月还在打橄榄球拿了超级碗,这个月又拿了奥斯卡,啧啧
avatar
m*9
14
嗯,你说的没错,我弄错了。题目是只给个range就够了,并不是一组数。肯定有更好
的方法。

【在 s*****r 的大作中提到】
: 这样还是要一个个遍历所有的range, 有没有不需要一个个range遍历的.
: 另外, 最开始的数组都没有用, 直接for loop 从begin开始到end, 一个个查是否在
: range就行了.
:
: ]=

avatar
H*7
15
这两天算是给刘家争回了点光
avatar
z*k
16
应该先简化第一个Range系列,然后只比较其begin和end,不应该一一遍历.
avatar
k*e
17
range tree
i don't remember the exact name.
Computational Geometry Algorithms and Applications, chapter 10
nlgn preprocessing, O(lgn+matched#)

efficient
range
a

【在 s*****r 的大作中提到】
: 一个很小的公司, 要我一个小时写个程序发过去, 用了一个很simple的算法,就是从给
: 定range的每个integer对比一个range一个range的看, 大家看看这题如果要efficient
: 怎么弄?
: Write a function that takes a list of integer ranges and an additional range
: and prints all non-overlapping ranges from the additional range.
: For example, given a list or ranges [6 – 10], [17 – 24], [15 – 19] and a
: new range [8 – 28], your function should print [11 – 14], [25 - 28].

avatar
m*f
18
I think the basic idea is sort the range number first by nlogn, then use
binary search to find the two range ends in the sorted list, so you don't
have to check the whole list
just O(logn) + O(matched)

【在 k***e 的大作中提到】
: range tree
: i don't remember the exact name.
: Computational Geometry Algorithms and Applications, chapter 10
: nlgn preprocessing, O(lgn+matched#)
:
: efficient
: range
: a

avatar
x*y
19
1. Sort the lower boundary, and the upper boundary separately (O(nlogn)),
from the smallest lower boundary min_low (6 in your e.g), and assume upp is
the upper boundary corresponding(10 in e.g) to lower boundary, set old_upp
to min_low;
2. find position of upp in the array of lower boundary, and in the lower
boundary for all the values less than upp, if the largest corresponding
upper bound is bigger than upp, set old_upp to upp and set upp to the
largest corresponding upper bound, and do step

【在 s*****r 的大作中提到】
: 一个很小的公司, 要我一个小时写个程序发过去, 用了一个很simple的算法,就是从给
: 定range的每个integer对比一个range一个range的看, 大家看看这题如果要efficient
: 怎么弄?
: Write a function that takes a list of integer ranges and an additional range
: and prints all non-overlapping ranges from the additional range.
: For example, given a list or ranges [6 – 10], [17 – 24], [15 – 19] and a
: new range [8 – 28], your function should print [11 – 14], [25 - 28].

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