Count Sorted Vowel Strings
给 (a, e, i, o, u) 5个元音, 求满足字典序下n个字母的组合.
dp[i][j] = 前i个字符自称的j个元音的总数.
dp[1][i] = [1...5]
dp[i][1] = 1 (a, e, i, o, u)
dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
class Solution {
public int countVowelStrings(int n) {
int[][] dp = new int[n + 1][6];
for(int i = 1; i <= 5; i++) {
dp[1][i] = i;
}
for(int i = 1; i <= n; i++) {
dp[i][1] = 1;
}
for(int i = 2; i <= n; i++) {
for(int j = 2; j <= 5; j++) {
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
}
}
return dp[n][5];
}
}