Skip to content

Latest commit

 

History

History
13 lines (13 loc) · 270 Bytes

96. Unique Binary Search Trees.md

File metadata and controls

13 lines (13 loc) · 270 Bytes
class Solution {
public:
    int numTrees(int n) {
        vector<int> v(n + 1, 0);
        v[0] = v[1] = 1;
        for (int i = 2; i <= n; ++i)
            for (int j = 1; j <= i; ++j)
                v[i] += v[j - 1] * v[i - j];
        return v[n];
    }
};