#96

Unique Binary Search Trees

specialist · 655 · lc medium +30 · verified · 63.4% accepted · 10,975 likes · top 66%

play →

Description

Given integer n, count and return the number of structurally unique BSTs that hold exactly n nodes with distinct values 1 through n.

Example 1:

Input: n = 3
Output: 5

Example 2:

Input: n = 1
Output: 1

Code

1
2
3