Populating Next Right Pointers in Each Node
@cwang it's a perfect binary tree!
this solution is not O(n) time
@anat By extra space usually it refers to not using any additional data Structure. Though you can clarify this with the Interviewer
what a wonderful solution!!!!!
Nice hint,which help me a lot.
@happykimi Not sure what you mean. I am considering that case. Did you overlook my and root.left?
No one has replied
straightforward but O(N) space
recursive is guaranteed to not be a constant space solution!
@Fanchao true, there are repeated calculation in that code.
There is no need to add root->right in if(), since 'You may assume that it is a perfect binary tree (ie, all leaves are at the same level, and every parent has two children)'.
Beautiful !! Thanks for Sharing
Thanks for your post. However it would be better to share solution with correct code format and elaborated thoughts. Please read the FAQ for more info. Take a look at good sharing example
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.