String Patterns (Also for Core/Database Intern :)
Learn this problemProblem statement
Given the length of a word (wordLen) and the maximum number of consecutive vowels that it can
contain (maxVowels), determine how many unique words can be generated. Words will consist of
English alphabetic letters a through z only. Vowels are a, e, i, o, u; consonants
are the remaining 21 letters. In the explanations, v and c represent vowels and consonants.
Function
calculateWays(wordLen: int, maxVowels: int) → int
Complete the function calculateWays in the editor below.
calculateWays has the following parameters:
- 1.
int wordLen: the length of a word - 2.
int maxVowels: the maximum number of consecutive vowels allowed in a word
Returns
int: the number of well-formed strings that can be created, modulo 1000000007(109+7)
The result may be very large number, so return the answer modulo (109 + 7).
Note:
While the answers will be within the limit of a 32 bit integer, interim values may exceed that limit. Within the function, you may need to use a 64 bit integer type to store them.
Examples
Example 1
wordLen = 1maxVowels = 1return = 26
Example 2
wordLen = 4maxVowels = 1return = 412776
Example 3
wordLen = 4maxVowels = 2return = 451101Constraints
- 1 ≤ wordLen ≤ 2500
- 0 ≤ maxVowels ≤ n
More Snowflake problems
- Closest Target CharacterPHONE SCREEN · Seen Jul 2026
- Horizontal Pod AutoscalerSeen Jul 2026
- Minimum HeightOA · Seen Jul 2026
- Vowel SubstringSeen Jun 2026
- String Formation (Also for AI/ML Software Engineer Intern :)OA · Seen Jun 2026
- Efficient DeploymentsOA · Seen Jun 2026
- Character Frequencies Across Nested String ListsPHONE SCREEN · Seen Jun 2026
- Character Frequencies Across StringsPHONE SCREEN · Seen Jun 2026