Redian新闻
>
RTP 地区需要Rabies & Microchip 的看过来~
avatar
RTP 地区需要Rabies & Microchip 的看过来~# pets - 心有所宠
c*2
1
any good solution? Thanks.
avatar
b*n
2
2岁多的小孩今天一直喊腿疼,周日晚上的时候同边的脚被图钉扎了一下,不知道是不
是这个原因?他的破伤风的针follow the schedule. 不知道有没有知道的姐妹说一下
,多谢阿。
avatar
t*y
3
彻底被律师搞晕了,以前来版上问过J1 waiver后能不能直接递交485,老大的回答是可以的,当时问律师他也说可以,但现在俺的律师又说不一定了,问了学校的国际部,国际部的人说不清楚。版上有没有类似情况的,J1 waiver后一定要转成H1才能交485吗?多谢了!
avatar
t*j
5
算树层次的变体吧。

【在 c***2 的大作中提到】
: any good solution? Thanks.
avatar
s*a
6
腿疼,不是脚疼,应该跟图钉没有太大的关系吧。是不是生长疼哟?如果不放心,还是
问问医生吧。
avatar
d*2
7
我有一个朋友与你类似,J1waiver, 但没有H1
上个月已经FP了,估计马上应该得到绿卡了吧
avatar
j*e
8
小吉找到家了么?
avatar
d*t
9
可以用递归,返回值是从该节点出发到leaf的最长路径(可以是个vector)。对于每个
node,比较子节点返回的path,保留长的一条,pass上去。
avatar
b*n
10
我也觉得挺奇怪的,明天问问医生吧。
avatar
t*y
11
多谢,多谢。找个律师本来是为了省心,结果现在天天让我操心。
avatar
a*t
12
找到啦 昨天晚上就送走啦

【在 j*****e 的大作中提到】
: 小吉找到家了么?
avatar
j*u
13
BFS or DFS w/ a global var that stores max depth?

【在 c***2 的大作中提到】
: any good solution? Thanks.
avatar
b*n
14
我也觉得挺奇怪的,明天问问医生吧。
avatar
m*r
15
bless顺利!
此外,请问J1 wavier有多久的时间不用换其他身份?
这个时间够485从申请到拿到?

【在 t******y 的大作中提到】
: 多谢,多谢。找个律师本来是为了省心,结果现在天天让我操心。
avatar
j*e
16
那就好,真好RP。

【在 a********t 的大作中提到】
: 找到啦 昨天晚上就送走啦
avatar
s*u
17
int LongestPath(struct Tree * T)
{
if (T->left == NULL && T->right == NULL)
return 0;
return 1 + std::max(LongestPath(T->left), LongestPath(T->right));
}
avatar
k*w
18
我家老大曾经也喊腿疼,也是两岁左右,我还带他看医生,最后什么也没查出来。你说
他是骗我,不像,可是到现在我也没有弄明白他为什么会腿疼

【在 b**********n 的大作中提到】
: 2岁多的小孩今天一直喊腿疼,周日晚上的时候同边的脚被图钉扎了一下,不知道是不
: 是这个原因?他的破伤风的针follow the schedule. 不知道有没有知道的姐妹说一下
: ,多谢阿。

avatar
t*6
19
可以的。我正准备递485呢,H1还没批下来呢,就用J1。
avatar
a*t
20
嘻嘻...小吉探险之狼窝一日游~

【在 j*****e 的大作中提到】
: 那就好,真好RP。
avatar
d*t
21
我这里假设你说的是Binary tree。其它的TREE无非就是子节点多一些,要比较的子
path多一些。
vector* longestpath(node* root)
{
vector* path;
if(root==NULL)
{
path = new vector;
}
else
{
vector* left = longestpath(root->left);
vector* right = longestpath(root->right);
path = left->size()>right->size()?left:right;
path->push_back(root);
}
return path;
}
然后根据要求加个wrapper function就行了
avatar
w*4
22
我妈妈跟我提过,有的小孩在生长的过程中会有疼痛现象(又叫生长痛)。不过最好还
是看一下医生。
avatar
t*6
23

到J1的截至日期,期间不能办延长了。
看J1还省多久了,如果太短可能不够,但可以转H1呀。

【在 m*******r 的大作中提到】
: bless顺利!
: 此外,请问J1 wavier有多久的时间不用换其他身份?
: 这个时间够485从申请到拿到?

avatar
j*e
24
昨天听说上次跑出来和Chili玩的大血猎就那么丢了,都怪我RP不好,抓不住,哎
avatar
d*t
25
要是只是返回长度,每次返回个最长的长度值就行了。either way,复杂度都是O(n)
avatar
b*n
26
I will call the Doctor today. Many thanks!
avatar
t*y
27
多谢,多谢。我现在真的怀疑我的律师的水平了,咋没个准啊,一会一个说法。

【在 t******6 的大作中提到】
: 可以的。我正准备递485呢,H1还没批下来呢,就用J1。
avatar
a*t
28
是嘛? 啥时候的事情呀?
pat pat 不是RP不好,可能是没缘份吧~~
avatar
c*2
29
to get the *path*, not the length of the path.

【在 s*****u 的大作中提到】
: int LongestPath(struct Tree * T)
: {
: if (T->left == NULL && T->right == NULL)
: return 0;
: return 1 + std::max(LongestPath(T->left), LongestPath(T->right));
: }

avatar
i*9
30
我家两岁小孩分不清疼和痒,痒也说成疼,我给她挠挠就好了。。。
avatar
m*r
31
多谢!
J1有5年啊,如果第2年办waiver,那就是还有3年,办GC怎么样都够了阿
我有没有理解对?

【在 t******6 的大作中提到】
:
: 到J1的截至日期,期间不能办延长了。
: 看J1还省多久了,如果太短可能不够,但可以转H1呀。

avatar
a*o
32
TRP?哈哈
avatar
c*2
33
There is a solution at
http://www.ihas1337code.com/search/label/binary%20tree
/** See my comments **/
int maxDepthIterative(BinaryTree *root) {
if (!root) return 0;
stack s;
s.push(root);
int depth = 1, maxDepth = 0;
BinaryTree *prev = NULL;
while (!s.empty()) {
BinaryTree *curr = s.top();
if (!prev || prev->left == curr || prev->right == curr) {
if (curr->left) {
depth++;
s.push(curr->left);
} else if (curr->right) {
depth++;
s.push(curr->right);
}
} else if (curr->left == prev) {
if (curr->right) {
depth++;
s.push(curr->right);
}
} else {
depth--;
s.pop();
}
prev = curr;
if (depth > maxDepth)
maxDepth = depth;
/** At this point, the stack contains the longest reversed path
We can do a reverse copy into a queue;
**/
}
/** The queue will have the longest path **/
return maxDepth;
avatar
w*r
34
我儿子也是,想让我挠挠的时候,都可怜兮兮的喊疼.
avatar
a*t
35
5555....又被发现大错字

【在 a***o 的大作中提到】
: TRP?哈哈
avatar
c*2
36
This seems a good one. But requires a lot of help from high-level languages
(JAVA/C++).

【在 d*****t 的大作中提到】
: 我这里假设你说的是Binary tree。其它的TREE无非就是子节点多一些,要比较的子
: path多一些。
: vector* longestpath(node* root)
: {
: vector* path;
: if(root==NULL)
: {
: path = new vector;
: }
: else

avatar
b*1
37
生长疼,长个子的时候容易出现,女儿小时候也有
avatar
a*t
38
没人理我,大概好多人都不需要~

【在 a***o 的大作中提到】
: TRP?哈哈
avatar
d*t
39

languages
嗯?vector, stack 和 queue都是STL container,为什么需要a lot of help?

【在 c***2 的大作中提到】
: This seems a good one. But requires a lot of help from high-level languages
: (JAVA/C++).

avatar
u*b
40
我家也有,弄不明白,下次见儿医问问。
avatar
l*e
41
什么是microchip啊!!!!我觉得我们家lele肯定没有
avatar
K*g
42
get the depth first, then use recursive/stack to print that path.

【在 c***2 的大作中提到】
: any good solution? Thanks.
avatar
p*e
43
如果不是脚疼 是腿疼 很有可能就是长太快了 给娃补点钙 吃了就不疼了 外甥女 和我
娃都是吃了就好了

【在 b**********n 的大作中提到】
: 2岁多的小孩今天一直喊腿疼,周日晚上的时候同边的脚被图钉扎了一下,不知道是不
: 是这个原因?他的破伤风的针follow the schedule. 不知道有没有知道的姐妹说一下
: ,多谢阿。

avatar
a*t
44
就是植入皮肤下的电子芯片,如果狗狗走丢了被人捡到,可以去vet一扫,就有主人的信
息了
因为有时候tag会磨损或丢失,这个更安全

【在 l*****e 的大作中提到】
: 什么是microchip啊!!!!我觉得我们家lele肯定没有
avatar
c*2
45
Try to do it in C. :-)

【在 d*****t 的大作中提到】
:
: languages
: 嗯?vector, stack 和 queue都是STL container,为什么需要a lot of help?

avatar
c*d
46
Re:
Both my kids had it from 2 to 4.
It can last a day or two. Both my kids complained about thighs right above
the knees. No problem.

【在 b**********1 的大作中提到】
: 生长疼,长个子的时候容易出现,女儿小时候也有
avatar
i*e
47
Your solution is basically a bottom-up approach. However, there is a problem
. You are allocating the vectors dynamically, which leaks memory after the
function finishes. How are you going to clean up? There is no easy way.
I know you allocate it dynamically instead of statically is to use pointer
to reference, thus avoiding copy by value for efficiency purposes. Another
problem is you are also using more memory than you should. When you found
the left branch has a greater depth, you don't clean up the right branch,
therefore it is still occupied in memory. If you choose to clean up the
right branch, you end up spending extra time to process the right branch.
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

【在 d*****t 的大作中提到】
: 我这里假设你说的是Binary tree。其它的TREE无非就是子节点多一些,要比较的子
: path多一些。
: vector* longestpath(node* root)
: {
: vector* path;
: if(root==NULL)
: {
: path = new vector;
: }
: else

avatar
b*n
48
Great to know!
Thanks for all the replies! Now my baby stopped complaining and I think it
is growing pain.
avatar
d*t
49
对,应该在不用的时候删除短的那个vector. 但是用递归通常会用到多余的data, 这个
基本上不避
免。至于删除不需要的branch所花的时间并不比用非递归时间多,相当于非递归中把节
点从stack
里一个一个pop出来的过程。
总的来说用非递归通常会快一些,但是写起来会比较麻烦一些,我觉得是各有利弊的~

problem
the
way.
pointer
Another
found
branch,
the
branch.

【在 i**********e 的大作中提到】
: Your solution is basically a bottom-up approach. However, there is a problem
: . You are allocating the vectors dynamically, which leaks memory after the
: function finishes. How are you going to clean up? There is no easy way.
: I know you allocate it dynamically instead of statically is to use pointer
: to reference, thus avoiding copy by value for efficiency purposes. Another
: problem is you are also using more memory than you should. When you found
: the left branch has a greater depth, you don't clean up the right branch,
: therefore it is still occupied in memory. If you choose to clean up the
: right branch, you end up spending extra time to process the right branch.
: 一些常见面试题的答案与总结 -

avatar
n*y
50
嗯,我娃儿折腾的时候就叫腿疼脚疼啥的。其实我觉得他是便秘。
avatar
i*e
51
How about this top-down approach?
Basically we cannot avoid copying the current path to longest path every
time we update maxDepth, unless we obtain the value of maxDepth by traversing the entire tree beforehand.
void findLongestPath(BinaryTree *p, int &maxDepth, vector &path
, vector &longestPath) {
if (!p) return;
path.push_back(p);
if (!p->left && !p->right && path.size() > maxDepth) {
maxDepth = path.size();
longestPath = path;
}
findLongestPath(p->left, maxDepth, path, longestPath);
findLongestPath(p->right, maxDepth, path, longestPath);
path.pop_back();
}
vector findLongestPath(BinaryTree *root) {
vector longestPath;
vector path;
int maxDepth = 0;
findLongestPath(root, maxDepth, path, longestPath);
return longestPath;
}
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

【在 d*****t 的大作中提到】
: 对,应该在不用的时候删除短的那个vector. 但是用递归通常会用到多余的data, 这个
: 基本上不避
: 免。至于删除不需要的branch所花的时间并不比用非递归时间多,相当于非递归中把节
: 点从stack
: 里一个一个pop出来的过程。
: 总的来说用非递归通常会快一些,但是写起来会比较麻烦一些,我觉得是各有利弊的~
:
: problem
: the
: way.

avatar
d*t
52
Top down也不错,基本上是在pre-order遍历的同时加上一些变量,传一些参数

traversing the entire tree beforehand.
&path

【在 i**********e 的大作中提到】
: How about this top-down approach?
: Basically we cannot avoid copying the current path to longest path every
: time we update maxDepth, unless we obtain the value of maxDepth by traversing the entire tree beforehand.
: void findLongestPath(BinaryTree *p, int &maxDepth, vector &path
: , vector &longestPath) {
: if (!p) return;
: path.push_back(p);
: if (!p->left && !p->right && path.size() > maxDepth) {
: maxDepth = path.size();
: longestPath = path;

avatar
a*8
53
Depth first, starting from root
or Breadth first
avatar
P*l
54
We cannot avoid bookmarking the path when the we find a local maximum path.
But we can use bit map to keep track the path rather than using vector of
pointers. The bitmap can be as simple as a long integer, 0 is for left child
and 1 is for right child. The current depth needs to be saved in this case.

traversing the entire tree beforehand.
path

【在 i**********e 的大作中提到】
: How about this top-down approach?
: Basically we cannot avoid copying the current path to longest path every
: time we update maxDepth, unless we obtain the value of maxDepth by traversing the entire tree beforehand.
: void findLongestPath(BinaryTree *p, int &maxDepth, vector &path
: , vector &longestPath) {
: if (!p) return;
: path.push_back(p);
: if (!p->left && !p->right && path.size() > maxDepth) {
: maxDepth = path.size();
: longestPath = path;

avatar
P*l
55
Depth first is better. Or you have some better idea saving the path?

【在 a*******8 的大作中提到】
: Depth first, starting from root
: or Breadth first

avatar
l*o
56
2个问题:
1. 为什么一定要返回vector*, vector行吗?
2. 仅仅把左右两边的path之中长的那条加入vector,是不是自己当前节点也要加进去
啊?
谢谢!

【在 d*****t 的大作中提到】
: 我这里假设你说的是Binary tree。其它的TREE无非就是子节点多一些,要比较的子
: path多一些。
: vector* longestpath(node* root)
: {
: vector* path;
: if(root==NULL)
: {
: path = new vector;
: }
: else

avatar
d*t
57
1.可以,但是会比较费空间和时间。因为copy constructor要把vector里的节点一个一
个copy到新的里。
2.对
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。