m*p
2 楼
哪位大侠知道原因?
void flatten(TreeNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (root==NULL) return;
TreeNode* curr = root;
while (curr) {
if (curr->left) {
TreeNode* temp = curr->left;
while (temp->right) {
temp = temp->right;
}
temp->right = curr->right;
curr->right = curr->left;
}
curr=curr->right;
}
return;
}
void flatten(TreeNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (root==NULL) return;
TreeNode* curr = root;
while (curr) {
if (curr->left) {
TreeNode* temp = curr->left;
while (temp->right) {
temp = temp->right;
}
temp->right = curr->right;
curr->right = curr->left;
}
curr=curr->right;
}
return;
}
d*o
3 楼
应该没有车,就是一个塞小孩的袋子,而且这个袋子很可能只适用于某个牌子的
stroller和car seat
stroller和car seat
n*d
4 楼
After you set curr->right = curr->left, you forgot to set curr->left to NULL
, so while loop becomes dead loop
【在 m**p 的大作中提到】
: 哪位大侠知道原因?
:
: void flatten(TreeNode *root) {
: // Start typing your C/C++ solution below
: // DO NOT write int main() function
: if (root==NULL) return;
:
: TreeNode* curr = root;
: while (curr) {
: if (curr->left) {
, so while loop becomes dead loop
【在 m**p 的大作中提到】
: 哪位大侠知道原因?
:
: void flatten(TreeNode *root) {
: // Start typing your C/C++ solution below
: // DO NOT write int main() function
: if (root==NULL) return;
:
: TreeNode* curr = root;
: while (curr) {
: if (curr->left) {
m*p
6 楼
Thanks! I see it became a loop.
相关阅读
急问:现在H4拿到签证后有规定必须3个月内入境么? (转载)从找工作角度比较MS in east asian studies和bilingual educationH1B请问大家是先发OFFER再背景调查还是先调查再OFFER?不办H1b的补救措施?opt 期间工作eligibility选择上学和上班究竟哪个更累一个研发onsite 问题,需要注意什么?onsite后这样回email是不是就没戏了?面试穿个卡其裤+衬衫领带合适么google如果折了,多久以后可以再投简历 谢谢急:这个采样问题如何回答?谢谢先两轮电面十天后,收到通知要推荐信【请问】H-1B申请递交之后会有notice过来么?Yelp面试被放鸽子这么办?紧急求建议,H1b可能有1到2天gap请问人在美国要是想找国内的工作通过什么途径找呢哪里可以印名片?紧急求助,H1b transfer的大问题弱问 公司不给办H1b的原因