• Skip to primary navigation
  • Skip to content
  • Skip to footer
zhicheng xie's demo blog
  • Quick-Start Guide

    Your Name

    I am an amazing person.

    • Somewhere

    Unique Binary Search Trees

    less than 1 minute read

    <-M 96> Unique Binary Search Trees

    class Solution {
    public:
        int numTrees(int n) {
            vector<int> check(n + 1, 0);
    
            check[0] = 1;
            check[1] = 1;
            for(int i = 2; i <= n; i++)
                for(int k = 1; k <= i; k++)
                    check[i] += check[k - 1] * check[i - k];
            return check[n];
        }
    };
    

    Tags: Algorithms, C++, Leetcode

    Updated: June 24, 2022

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    You may also enjoy

    Decode Ways

    less than 1 minute read

    <-M 91> Decode Ways

    Word Break

    less than 1 minute read

    <-H 139> Word Break

    Distinct Subsequences

    less than 1 minute read

    <-H 115> Distinct Subsequences

    Edit Distance

    less than 1 minute read

    <-H 72> Edit Distance

    • Follow:
    • Feed
    © 2023 zhicheng xie's blog. Powered by Jekyll & Minimal Mistakes.