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.
相关阅读
为什么查不到OPT的状态呢Recuiter 主动联系 VS 内推berkeley,stanford的那些online certificate含金量高么?一个C++的问题!问一个OPT的问题找最近的点,这题咋解?Qualcomm H1B change of employer petitionphone interview一般设在什么时间比较好collabedit怎么cancel啊如何实现hashMap里value的unique关于老中烙印讨论的一点倡议What is the best way to choose a random value in a stream?Onsite还是电面?关于zynga的一些情况求 fb facebook 的refer, 谢谢跳過電面直接onsite为什么amazon这么一个大公司盈利却很少?Arista Networks 在狂招网络软工发包子,祝大家找到满意的新工作一道image processing题