One-line solution | Math | No DP, no Big Integers | O(1) time, space
Let me start with the answer itself, you just need to return the following:\n\n\n\nFor example, in Ruby:\n\ndef count_vowel_strings(n)\n  (n + 1) * (n + 2) * (n
Let me start with the answer itself, you just need to return the following:\n\n![image](https://assets.leetcode.com/users/images/1c609db6-788a-4742-b5ca-35c53c57611b_1610888570.431183.png)\n\nFor example, in Ruby:\n```\ndef count_vowel_strings(n)\n  (n + 1) * (n + 2) * (n + 3) * (n + 4) / 24\nend\n```\n\nSee the explained solution further down.\n\n# 1. Simplify the problem\nThe "vowels" part in the problem statement makes it more confusing and makes it sound more complex, let\'s rephrase it using numbers:\n\n> Given an integer n, return the number of numbers of length n that consist only of digits 1 to 5 and all digits are non-decreasing.\n\nFor example, given `n = 2`, we need to count: 11, 12, 13, 14, 15, 22, 23, 24, 25, 33, 34, 35, 44, 45, 55.\n\nThe answer to the rephrased problem will be the same as to the original problem, these problems are equivalent. \n\n# 2. Solve the simple problem\nThe problem defined in part 1 is known as a problem counting the number of **combinations with repetitions**.\nIn particular, we need to choose **n** digits from the pool of **5** digits with repetitions.\n\nWhy combinations, but not permutations? Because the number needs to be sorted (the digits should be non-decreasing), so we need to only count "112", but not "121", "211".\n\nThe easiest way to calculate the number of combinations with repetitions is to use the folowing formula:\n![image](https://assets.leetcode.com/users/images/cea1928c-012e-48f6-b8ad-88686529d7cb_1610888870.9998922.png)\n\n\n\nIf we apply this formula to our problem where we choose n from 5 (k = n, n = 5), it can be then simplified to this:\n![image](https://assets.leetcode.com/users/images/29776b71-5d21-4319-a998-f3cb6f668f5a_1610888920.7676246.png)\n\n\n\nwhich is the answer!\n\nThank you for reading through :)\n
['Math', 'Combinatorics']