Unique Binary Search Trees

Input: 3
Output: 5
Explanation:
Given n = 3, there are a total of 5 unique BST's:
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2
/ / \ \
2 1 2 3
    2         1          
/ \ + / \
{1} {0} {0} {2}
T[1]*T[0] T[0]*T[1]
      1              
/ \
{0} {2, 3}
T[0] * T[2]
      2             
/ \
{1} {3}
T[1] * T[1]
     3            
/ \
{1, 2} {0}
T[2] * T[0]

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Navneet Ojha

Navneet Ojha

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.