LeetCode Validate Binary Search Tree

Judge Rules:

1. the maximum value of left subtree < root's value

2. the minimum value of right subtree > root's value

3. both the left and right subtrees are meet the above conditions.

4* empty tree is valid!

http://www.cnblogs.com/remlostime/archive/2012/11/16/2772629.html

C header file<limits.h> defines as follows:

#define INT_MAX        2147483647
#define INT_MIN       (-INT_MAX-1)
 

Attach:

OJ's Binary Tree Serialization:

The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.

Here's an example:

   1
  / \
 2   3
    /
   4
    \
     5

The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".


原文地址:https://www.cnblogs.com/CathyGao/p/3024748.html