[LeetCode][1641. Count Sorted Vowel Strings] Image Explanation: Distributing N Balls into 5 Boxes, Some Boxes May Be Empty
By Long Luo
This article is the solution Image Explanation: Distributing N Balls into 5 Boxes, Some Boxes May Be Empty of Problem 1641. Count Sorted Vowel Strings.
Math
Every vowel string is start by , and there are strings.
How to distribute strings into the boxes, some boxes may be empty?
Imaging that there are balls, we have to put them in to boxes represented by the five vowels, as the picture shows.
Once the number of characters in each box were fixed, the string is fixed.
Therefore, how many ways are there to put balls in boxes, and the boxes can be empty?
The combinatorics explanation is here.
-
balls in boxes, box can not empty: .
-
balls in boxes, box can be empty: .
1 | public static int countVowelStrings(int n) { |
Analysis
- Time Complexity: .
- Space Complexity: .
All suggestions are welcome.
If you have any query or suggestion please comment below.
Please upvote👍 if you like💗 it. Thank you:-)
Explore More Leetcode Solutions. 😉😃💗