Skip to content
Veltoryx Technologies
ProProblem 104● MediumLeetCode #96 ↗3 min readUpdated 30 October 2026

Unique Binary Search Trees

Calculate the number of structurally unique BSTs with n nodes using Catalan dynamic programming.

01The problem

Given an integer n, return the number of structurally unique BST's (binary search trees) which have exactly n nodes of unique values from 1 to n.

text
n = 3

  1         3     3      2      1
   \       /     /      / \          3     2     1      1   3      2
   /     /       \                   2     1         2                 3

Output: 5

Constraints

  • 1 <= n <= 19

Loading the rest of the lesson…