Skip to content

Practice Unique Binary Search Trees

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#96
LeetCode Problem

Unique Binary Search Trees

Problem Statement

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

Source: Unique Binary Search Trees on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 3
Output
5

# Example 2

Input
n = 1
Output
1

Constraints

1 <= n <= 19

Related LeetCode Problems

Practice more problems similar to Unique Binary Search Trees.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.