LeetCode.96

  数列肯定是有规律的,然后查阅到卡特兰数的前25个当打表题做:

class Solution {
public:
    int numTrees(int n) {
        long long table[] = {1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190, 6564120420, 24466267020, 91482563640, 343059613650, 1289904147324};
        return table[n];
    }
};

  

原文地址:https://www.cnblogs.com/darkchii/p/13585040.html