题目
Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.
A string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.
解题思路
排列组合问题,相当于把n个小球,分成5个部分,一共有多少分法
代码
class Solution:
def countVowelStrings(self, n: int) -> int:
return math.comb(n + 4, 4)