short python solution


  • 0
    Y

    0_1491385181580_屏幕快照 2017-04-05 17.38.57.png

        def numTrees(self, n):
            ans = [1]
            for i in range(1,n+1):
                tmp = 0
                for j in range(i):
                    tmp += ans[j]*ans[i-j-1]
                ans.append(tmp)
            return ans[-1]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.