public int numTrees(int n) {
        if (n < 2)
            return 1;
        int[] count = new int[n + 1];
        count[0] = 1;
        count[1] = 1;
        // count[2] = count[0] * count[1]
        //          + count[1] * count[0]
        // count[3] = count[0] * count[2]
        //          + count[1] * count[1]
        //          + count[2] * count[1]
        for (int i = 2; i < n + 1; ++i) {
            for (int j = 0; j < i; ++j) {
                count[i] += count[j] * count[i - j - 1];
            }
        }
        return count[n];
    }