活跃农民
- 积分
- 495
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2013-10-13
- 最后登录
- 1970-1-1
|
lz给的tree
1
2 3
4 5 6 7
不符合原题的描述: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty,
所有的right child必须是leaf而且必须有left sibling或者是没有
原题的example:
1
/ \
2 3
/ \
4 5
output
4
/ \
5 2
/ \
3 1
想象在4上面钉了一颗钉子,然后余下的旋转了一百八十度
也就是对于每个left child,parent变成了 right child,right sibling变成了left child
|
|