One line solution | Math | O(1) | Fastest
Intuition\nThis is a simple math problem. Let\'s redefined as "no of ways to select N vowels where each vowel can be repeated."\n Describe your first thoughts o
# Intuition\nThis is a simple math problem. Let\'s redefined as "no of ways to select N vowels where each vowel can be repeated."\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nThe formulae is (n+r-1)C r , where n = 5(number of vowels), r = N.\nSo the formulae is reduced to (4+r)C r, which can be further simplified as:\n(n + 1) * (n + 2) * (n + 3) * (n + 4) / 24 \nny using the properties of nCr.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n\n\n![Screenshot 2024-08-07 151231.png](https://assets.leetcode.com/users/images/a7093b04-0a5e-4639-9812-93ec8bc09a7e_1723024254.274418.png)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int countVowelStrings(int n) {\n        //(n+r-1)C r, r=n(given), n=5(number of vowels)\n        //ans would be (n+4)!/((n!)*24)\n        return (n + 1) * (n + 2) * (n + 3) * (n + 4) / 24;\n    }\n}\n```
['Math', 'Combinatorics', 'C++', 'Java']