Tuesday, June 5, 2018

Leetcode 98: Validate binary search tree

June 5, 2018

Introduction


It is my most favorite algorithm to apply recursive solution. To simplify the solution, we can pass the maximum value and minimum value for each node; The rule of maximum and minimum will also take care of the binary search tree property, the root value is bigger than left node and smaller than right now.

Algorithm


I just quickly read the recursive solution. I put together a gist for the solution I like here.

Time spent: 9:00 PM - 9:10 PM



No comments:

Post a Comment