Posted on

Description

Submission

class Solution {
    int dp[51][5];
public:
    int countVowelStrings(int n) {
        return countVowelStringsUtil(0, 4, n);
    }
    
    int countVowelStringsUtil(int prevBlock, int blocks, int n) {
        if(dp[prevBlock][blocks] != 0) return dp[prevBlock][blocks];
        if(blocks == 0) return 1;
        int total = 0;
        for(int i = prevBlock; i <= n; ++i) {
            total += countVowelStringsUtil(i, blocks-1, n);
        }
        return dp[prevBlock][blocks]=total;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *