Structurally distinct BSTs

Write codeMedium20 min

Your task

Given an integer n, return the number of structurally distinct binary search trees that store the values 1..n exactly once. n is between 0 and 19. (For n=0 there is one tree: the empty tree.)

Examples

num_trees(n: int) -> int
Example 1
Inputnum_trees(3)
Output5