今際の国の呵呵君
Wednesday, January 7, 2015
[LintCode]Remove Node in Binary Search Tree
删除的时候三种情况:
没有子节点
有一个子节点
有两个子节点
三种情况和相应的删除方法如下图所示:
代码如下:
注意第26 - 29行非常简洁地处理了case 0 和 case 1,是值得背下来经常使用的。
1 comment:
Unknown
July 8, 2015 at 1:33 PM
Thank you! Clean and elegant!
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Thank you! Clean and elegant!
ReplyDelete