Image Explanation: Distributing N Balls into 5 Boxes, Some Boxes May Be Empty
Leetcode 1641. Count Sorted Vowel Strings.\n\n# Math \n\nEvery vowel string is start by $a, e, i, o, u$, and there are $N$ strings. \n\nHow to distribute $N$ st
[Leetcode](https://leetcode.com/) [1641. Count Sorted Vowel Strings](https://leetcode.com/problems/count-sorted-vowel-strings/).\n\n# Math \n\nEvery vowel string is start by $a, e, i, o, u$, and there are $N$ strings. \n\nHow to distribute $N$ strings into the $5$ boxes, some boxes may be empty?\n\nImaging that there are $N$ balls, we have to put them in to $5$ boxes represented by the $5$ vowels, as the picture shows.\n\n![1621](https://assets.leetcode.com/users/images/2ae9e3a9-b0a9-4935-b0eb-cc7c41c24f76_1652232736.5699382.png)\n\nOnce the number of characters in each box were fixed, the string is fixed.\n\nTherefore, how many ways are there to put $N$ balls in $5$ boxes, and the boxes can be empty?\n\nThe combinatorics explanation is [Pentatope number](https://en.wikipedia.org/wiki/Pentatope_number).\n\n1. $N$ balls in $M$ boxes, box can not empty: $C(n - 1, m - 1)$.\n2. $N$ balls in $M$ boxes, box can be empty: $C(n + m - 1, m - 1)$.\n\n```java\n    public static int countVowelStrings(int n) {\n        return (n + 4) * (n + 3) * (n + 2) * (n + 1) / 24;\n    }\n```\n\n## Analysis\n\n- **Time Complexity**: $O(1)$.\n- **Space Complexity**: $O(1)$.\n\n------------\n\nAll suggestions are welcome. \nIf you have any query or suggestion please comment below.\nPlease upvote\uD83D\uDC4D if you like\uD83D\uDC97 it. Thank you:-)\n\nExplore More [Leetcode Solutions](https://leetcode.com/discuss/general-discussion/1868912/My-Leetcode-Solutions-All-In-One). \uD83D\uDE09\uD83D\uDE03\uD83D\uDC97\n\n
['Math', 'Dynamic Programming', 'Combinatorics', 'C++', 'Java']