1、Unique Binary Search Trees
1 class Solution { 2 public: 3 int numTrees(int n) { 4 if(n < 1) 5 return 1; 6 vector<int> res(n+1, 0); 7 res[0] = 1; 8 res[1] = 1; 9 for(int i=2; i<=n; i++) 10 { 11 for(int j=0; j<i; j++) 12 { 13 res[i] += res[j]*res[i-1-j]; 14 } 15 } 16 return res[n]; 17 } 18 };