331. Verify Preorder Serializati

2016-12-27  本文已影响0人  我是你的果果呀

One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as#.

    _9_
     /  \
   3     2
  / \      / \
 4  1   #   6
 / \  / \     / \
# # # #   # #
Example 1:  "9,3,4,#,#,1,#,#,2,#,6,#,#" Return  true
Example 2: "1,#" Return false

不为空的节点 ,有2个出点, 1个入点, 为空的有0个出点, 1个入点。

上一篇 下一篇

猜你喜欢

热点阅读