We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第一刷
最基础的解法没有实现,想的如何在每次inorder遍历的时候就更该树的结构。
有思路:每层要把root.left = None, 然后存储一个prev变量在返回的时候充当之前层数的parent指针,但实现起来写不对
看了答案,实现如下。需要重刷
class Solution(object): def increasingBST(self, root): self.prev = None self.parent = None self.inOrder(root) return self.parent def inOrder(self, root): if not root: return self.inOrder(root.left) if not self.parent: self.parent = root else: self.prev.right = root self.prev = root root.left = None self.inOrder(root.right)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
第一刷
最基础的解法没有实现,想的如何在每次inorder遍历的时候就更该树的结构。
有思路:每层要把root.left = None, 然后存储一个prev变量在返回的时候充当之前层数的parent指针,但实现起来写不对
看了答案,实现如下。需要重刷
The text was updated successfully, but these errors were encountered: