Redian新闻
>
T2 told me USCIS System is down
avatar
T2 told me USCIS System is down# EB23 - 劳工卡
l*n
1
电饭锅可能坏了,请推荐个好用的???
这两天做饭都夹生,做粥也做不好,米还是一粒一粒的。电饭锅可能坏了,能修吗?怎
么修?
或者买个新的,请大家推荐个好用的,牌子,在哪买?网上有卖好用的?WALMART?
多谢
avatar
l*d
2
implement the class
初始的 number pool 包含 [1...MAXLong]元素
checkout 返回number pool最小的元素,并取出
checkin 插入元素到number pool中
考虑只存checkout的元素,没太想清楚各种情况。。。
谁能说说最优的方案么
avatar
x*a
3
请问有什么好用的APP或者书吗?想让他提前准备一下。
他自己看YOUTUBE,颜色数数都会用英文了,但是一些必须的日常用语还不会。
请推荐。谢谢!
avatar
g*g
4
让我过一个小时打电话再去试试,晕
avatar
j*y
5
难道不是用 min heap ?

interface NumberPool {
public long checkout();
public void checkin(long i);
}
implement the class
初始number pool contains [1...MAXLong]
checkout 返回最小的元素
checkin 插入元素
考虑只存checkout的元素,没太想清楚各种情况。。。
谁能说说最优的方案么
还要发code 给他。。。在线等。。。

【在 l***d 的大作中提到】
: implement the class
: 初始的 number pool 包含 [1...MAXLong]元素
: checkout 返回number pool最小的元素,并取出
: checkin 插入元素到number pool中
: 考虑只存checkout的元素,没太想清楚各种情况。。。
: 谁能说说最优的方案么

avatar
M*s
6
Don't worry. He will pick up very quickly from friends in daycare.
avatar
T*n
7
down?
avatar
r*e
8
用一个set保存已经checkout的元素,同时用变量m记录下一个被checkout的元素
checkin(i):
如果 i 不在set里,没有影响;
如果 i 在set里,set.remove(i), if (i < m) m = i;
checkout()
ret = m
m = 从set.upper_bound(m)开始找,下一个不在set里的
set.insert(ret)
return ret

【在 l***d 的大作中提到】
: implement the class
: 初始的 number pool 包含 [1...MAXLong]元素
: checkout 返回number pool最小的元素,并取出
: checkin 插入元素到number pool中
: 考虑只存checkout的元素,没太想清楚各种情况。。。
: 谁能说说最优的方案么

avatar
x*a
9
还是WORRY啊,所以才想先让他接触一下。省得到时候FRUSTRATE了和老师发脾气。

【在 M********s 的大作中提到】
: Don't worry. He will pick up very quickly from friends in daycare.
avatar
c*m
10
You mean down?
avatar
r*e
11
初始条件是所有的数都在pool里,直接用heap太占空间

【在 j*****y 的大作中提到】
: 难道不是用 min heap ?
:
: interface NumberPool {
: public long checkout();
: public void checkin(long i);
: }
: implement the class
: 初始number pool contains [1...MAXLong]
: checkout 返回最小的元素
: checkin 插入元素

avatar
i*k
12
孩子会因为语言不通发脾气?那正好让老师教他怎么控制情绪。呵呵,开玩笑了。如果
真想学点英语,可以带孩子去听听故事,学唱几首儿歌,或跟其他讲英文的小朋友玩,
让他开开心心拣点英语。

【在 x*******a 的大作中提到】
: 还是WORRY啊,所以才想先让他接触一下。省得到时候FRUSTRATE了和老师发脾气。
avatar
o*t
13
是down。
avatar
l*d
14
checkout 元素很多后,还有improve的方法么?

【在 r*******e 的大作中提到】
: 用一个set保存已经checkout的元素,同时用变量m记录下一个被checkout的元素
: checkin(i):
: 如果 i 不在set里,没有影响;
: 如果 i 在set里,set.remove(i), if (i < m) m = i;
: checkout()
: ret = m
: m = 从set.upper_bound(m)开始找,下一个不在set里的
: set.insert(ret)
: return ret

avatar
j*2
15
没有get it...是只要一直保存check in过的最小元素吗?那跟running min有啥区别呀
?干嘛要初始化呀?
avatar
c*i
16
Interval Tree

【在 l***d 的大作中提到】
: checkout 元素很多后,还有improve的方法么?
avatar
l*d
17
不是的, 初始的元素有 maxlong 个,checkout的元素可能再次checkin

【在 j******2 的大作中提到】
: 没有get it...是只要一直保存check in过的最小元素吗?那跟running min有啥区别呀
: ?干嘛要初始化呀?

avatar
j*2
18
o,check out的就remove了是吗?
avatar
j*2
19
感觉这个是对的。。。

【在 c*******i 的大作中提到】
: Interval Tree
avatar
r*e
20
具体说说吧
如果保存还没被checkout的元素
checkin的时候怎么merge interval

【在 c*******i 的大作中提到】
: Interval Tree
avatar
b*u
21
我也碰到这题了
初始条件无穷个数
avatar
d*y
22
不是很明白题意。如果元素唯一的话,就可以用bitmap啊。
如果初有maxlong个元素,那么就是大约有4billion个数。用个bitmap,4G/8=512M。
checkout的时候从最小的开始扫描,直到发现第一个存在的数,clear bit后返回。
checkin的时候直接找到相应的位置,set bit就好了。
avatar
z*p
23

-The interval tree is a binary search tree where each node in the tree
stores a (key,value) pair: the key is the left end of an interval, and the
value is the right end.
-The interval tree for this problem is special in that the intervals are non
-overlapping.
-Initially, the tree only contain 1 node, the (1, MaxLong) pair.
-Check out value v: find the largest key that is smaller than v, look at its
value, assuming it looks like (k0,v0); if v0 is less than v, then v is not
in the pool, and the check out fails; otherwise, remove that node (interval)
and spilt the interval into two (k0, v-1), (v+1, v0), and insert them back
into the tree.
-Check in v: find two intervals: (a) the largest key that is smaller than v,
say (k0,v0), and (b) the smallest key that is larger than v, say (k1,v1),
in the interval tree (they are consecutive intervals for sure).
---if v < v0, then v is already in the pool, the check in can be ignored.
---else if v0 == v-1 && v+1 == k1, then merge (k0,v0) and (k1,v1) into (k0,
v1), by removing them from the tree and inserting back the merged interval
---else if v0 == v-1, update (k0,v0) to (k0,v)
---else if v+1 == k1, remove (k1,v1) from tree and insert back (v+1,v1)
---else, insert new node (v,v)
that's it.

【在 r*******e 的大作中提到】
: 具体说说吧
: 如果保存还没被checkout的元素
: checkin的时候怎么merge interval

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