human
I found an interesting problem on https://leetcode.com/problems/unique-binary-search-trees/:
Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n?

Example:

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

I tried it in Python, but could not do it. Can you solve it?

 ... Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.

class Solution:
     hash = {}
     def numTrees(self, n):
         """
         :type n: int
         :rtype: int
         """
         # return base case
         if n == 0:
             return 1
         if n == 1 or n == 2:
             return n
         
         # try fetching from hash
         try:
             return self.hash[n]
         except KeyError:
             pass
         
         # holds the sum
         resSum = 0
         
         # iterate i from 1 to n-1
         # should add up (0,4), (1,3), (2,2), (3,1), (4,0)
         for i in range(n):
             #print(i,n - (i+1))
             tempSum = self.numTrees(i) * self.numTrees(n - (i+1))
             #print(tempSum)
             resSum += tempSum
             
         # append to hash
         self.hash[n]=resSum
         return resSum