Redian新闻
>
BST查找next lowest 可以达到 O(lg N)? (转载)
avatar
xt
2
本来要种东北大萝卜,结果下错了种子,出来了一
大片的四川红萝卜,好在味道不错,而且炒菜冷拼
都好吃,坏处是不能冬天储藏:
avatar
d*e
3
【 以下文字转载自 JobHunting 讨论区 】
发信人: dilettante (半瓶醋), 信区: JobHunting
标 题: BST查找next lowest 可以达到 O(lg N)?
发信站: BBS 未名空间站 (Thu May 25 16:27:02 2017, 美东)
最近遇到next lowest的题,我写了下面这个inorder traversal (largest ->
smallest)的代码,但是对方坚持让我写 O(lg N),但是TreeNode 只有 left, right
pointer,没有parent pointer, 我觉得不可能啊,大牛有啥好办法吗?
public static Integer findNextLowest(TreeNode root, int target) {
Stack stack = new Stack<>();
TreeNode cur = root;
while (cur != null || stack.size() > 0) {
while (cur != null) {
stack.push(cur);
cur = cur.right;
}
TreeNode node = stack.pop();
if (node.val < target) return node.val; // found the next lowest
cur = node.left;
}
return null;
}
avatar
H*e
4
random
avatar
b*n
5
漂亮.
avatar
l*0
6
Amortized O(log(n))?
avatar
m*o
7
好像正常情况下485的处理是按RD,批准按PD
avatar
C*G
8
胭脂萝卜真漂亮。做四川泡菜最好吃。
能排种子吗?
avatar
w*m
9
把parent pointer放到argument里面吧
avatar
a*x
10
无序

【在 m****o 的大作中提到】
: rt
avatar
D*1
11
从照片还真不易看出来这是一个大萝卜。肯定种了几百颗吧,不能保存你怎么吃得完

【在 xt 的大作中提到】
: 本来要种东北大萝卜,结果下错了种子,出来了一
: 大片的四川红萝卜,好在味道不错,而且炒菜冷拼
: 都好吃,坏处是不能冬天储藏:

avatar
s*i
12
private static TreeNode findNextLowest(TreeNode root, int target){
TreeNode node = root;
TreeNode res = null;
while(node != null){
while(node != null && node.val >= target){
node = node.left;
}
while(node != null && node.val < target){
res = node;
node = node.right;
}
}
return res;
}
avatar
a*x
13
别逗了

【在 m****o 的大作中提到】
: 好像正常情况下485的处理是按RD,批准按PD
avatar
c*p
14
这个做四川泡菜最好了!!!
avatar
N*n
15
Define "next lowest". And what's this "root"? A sorted tree, a heap
or sth?

【在 d********e 的大作中提到】
: 【 以下文字转载自 JobHunting 讨论区 】
: 发信人: dilettante (半瓶醋), 信区: JobHunting
: 标 题: BST查找next lowest 可以达到 O(lg N)?
: 发信站: BBS 未名空间站 (Thu May 25 16:27:02 2017, 美东)
: 最近遇到next lowest的题,我写了下面这个inorder traversal (largest ->
: smallest)的代码,但是对方坚持让我写 O(lg N),但是TreeNode 只有 left, right
: pointer,没有parent pointer, 我觉得不可能啊,大牛有啥好办法吗?
: public static Integer findNextLowest(TreeNode root, int target) {
: Stack stack = new Stack<>();
: TreeNode cur = root;

avatar
n*s
16
Imagine this:
USCIS sort cases into separate boxes by their PD. They group cases with PD
within 10 days together. So let's say there are three groups:
group1: PD1st-10th, group2: PD 11th-20th, and group3: PD21st-31st.
In each group, there are ten cases.
Now VB passed those dates and all the cases are current. Three IOs head to
boxes to pick up those cases. The first IO takes all ten cases in group1,
second IO takes all ten cases in group2, third takes group3.
They go back and started to approve each case. Each IO approves one case
each day. So the first day, cases with PD in 1st, 11th, and 21st got
approved. The second day, PD in 2nd, 12th, and 22nd got GCs. ...
Above is just for illustration. You get the picture.
avatar
r*5
17
这不是春天种的水萝卜吗?东北春天都种,我今年也种了,春天种的好吃秋天种的不好
吃,没有萝卜味。

【在 xt 的大作中提到】
: 本来要种东北大萝卜,结果下错了种子,出来了一
: 大片的四川红萝卜,好在味道不错,而且炒菜冷拼
: 都好吃,坏处是不能冬天储藏:

avatar
n*s
18
Now imagine this:
On day 6, first IO decides to take 5 days off. At day 10, all cases are
approved except PD6th-10th. At day 11, first IO comes back and there are no more visa numbers. PD6th-10th have to wait.
avatar
xt
19
种子是从海泰买来的那个Sichuan Red.其实我是要China Red结果他们
给错了。

【在 C*******G 的大作中提到】
: 胭脂萝卜真漂亮。做四川泡菜最好吃。
: 能排种子吗?

avatar
t*9
20
I like your way of imagining the process flow.
Are you purely imagining or having some information which mentioned the
process flow?
I would not hold my breath for my approval. During my GC journey I find out
enjoying life and work do make my journey quicker.

no more visa numbers. PD6th-10th have to wait.

【在 n***s 的大作中提到】
: Now imagine this:
: On day 6, first IO decides to take 5 days off. At day 10, all cases are
: approved except PD6th-10th. At day 11, first IO comes back and there are no more visa numbers. PD6th-10th have to wait.

avatar
xt
21
没关系,我们这里找人吃萝卜不是问题啊。

【在 D*******1 的大作中提到】
: 从照片还真不易看出来这是一个大萝卜。肯定种了几百颗吧,不能保存你怎么吃得完
avatar
n*s
22
I generalized and simplified it from reading USCIS's documents that contain how they process 485 cases. No. not pure imagination. I would rather imagine to be a billionaire or a millionaire instead;-)

process flow?
out : enjoying life and work do make my journey quicker.

【在 t********9 的大作中提到】
: I like your way of imagining the process flow.
: Are you purely imagining or having some information which mentioned the
: process flow?
: I would not hold my breath for my approval. During my GC journey I find out
: enjoying life and work do make my journey quicker.
:
: no more visa numbers. PD6th-10th have to wait.

avatar
xt
23
应该是北方的水萝卜那个。前几天暖和的时候辣死人,这两天
凉快了,而且萝卜一下子变成了一两斤重,吃了点发现非常好吃
啊,又甜又脆,而且很有萝卜味道。炒菜做汤凉拌都好

【在 r***5 的大作中提到】
: 这不是春天种的水萝卜吗?东北春天都种,我今年也种了,春天种的好吃秋天种的不好
: 吃,没有萝卜味。

avatar
m*o
24
看来是布朗运动的结果
avatar
L*1
25
哎呀,很好啊
avatar
t*9
26
Have you heard anything on your EAD/AP?
I think this is really the thing that helps.
My mom already asked my plan for Chinese New Year. You know what she means.
Haha.

contain how they process 485 cases. No. not pure imagination. I would rather
imagine to be a billionaire or a millionaire instead;-)

【在 n***s 的大作中提到】
: I generalized and simplified it from reading USCIS's documents that contain how they process 485 cases. No. not pure imagination. I would rather imagine to be a billionaire or a millionaire instead;-)
:
: process flow?
: out : enjoying life and work do make my journey quicker.

avatar
L*1
27
埋在土里是不是可以存一段时间,我小时候冬天大人就是这样存萝卜的
avatar
n*s
28
No. I don't have plan to go back until next summer. Winter break is too
short for my kid to travel far.

rather

【在 t********9 的大作中提到】
: Have you heard anything on your EAD/AP?
: I think this is really the thing that helps.
: My mom already asked my plan for Chinese New Year. You know what she means.
: Haha.
:
: contain how they process 485 cases. No. not pure imagination. I would rather
: imagine to be a billionaire or a millionaire instead;-)

avatar
xt
29
有的萝卜可以有的萝卜不行。东北那个大红萝卜最耐储存,
本来今年要种一点存,结果种子错了。

【在 L***1 的大作中提到】
: 埋在土里是不是可以存一段时间,我小时候冬天大人就是这样存萝卜的
avatar
a*l
30
RP
RP不好就RIP了。

【在 m****o 的大作中提到】
: rt
avatar
y*8
31
做成萝卜干不就可以储藏了?

【在 xt 的大作中提到】
: 本来要种东北大萝卜,结果下错了种子,出来了一
: 大片的四川红萝卜,好在味道不错,而且炒菜冷拼
: 都好吃,坏处是不能冬天储藏:

avatar
t*9
32
You will definitely have your card at that time then.
Take care your family.

【在 n***s 的大作中提到】
: No. I don't have plan to go back until next summer. Winter break is too
: short for my kid to travel far.
:
: rather

avatar
C*G
33
知道了谢谢!

【在 xt 的大作中提到】
: 种子是从海泰买来的那个Sichuan Red.其实我是要China Red结果他们
: 给错了。

avatar
b*y
34
萝卜长得真好。MM是什么时候种的?长这么大需要多长时间?
avatar
xt
35
我是大老爷们,嘿嘿。
七月底下种的。我也从来没有见过这么大的水萝卜

【在 b**********y 的大作中提到】
: 萝卜长得真好。MM是什么时候种的?长这么大需要多长时间?
avatar
c*1
36
为什么要种罗拨??

【在 r***5 的大作中提到】
: 这不是春天种的水萝卜吗?东北春天都种,我今年也种了,春天种的好吃秋天种的不好
: 吃,没有萝卜味。

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