80: Validate binary search tree
Given a binary tree, check is this a binary search tree
Binary search tree is defined as:
leftsubtree of a node contains only nodes with valueslessthan theparentvaluerightsubtree of a node contains only nodes with valuesgreaterthan theparentvalueleft and rightsubtrees must bebinary search trees
Example 1
Input: 4
/ \
3 5
Output: true
Example 2
Input: 4
/ \
3 2
Output: false
Helpful article