Count Vowel Permutations
Updated
Problem statement
Return the number of length-n strings made only from a, e, i, o, and u that follow these rules:
amay be followed only bye.emay be followed only byaori.imay be followed bya,e,o, oru.omay be followed only byioru.umay be followed only bya.
Return the count modulo 1,000,000,007.
Function
countVowelPermutations(n: int) → intExamples
Example 1
n = 1return = 5Every single vowel is valid.
Example 2
n = 2return = 10The valid transitions are ae, ea, ei, ia, ie, io, iu, oi, ou, ua.
Example 3
n = 5return = 68Dynamic programming counts valid strings ending in each vowel after five positions.
Constraints
1 <= n <= 20000
More Zscaler interview questions
- Asteroid CollisionONSITE INTERVIEW · Seen Sep 2024
- Check Whether a Byte Is NonzeroONSITE INTERVIEW · Seen Sep 2024
- Longest Common Subsequence LengthONSITE INTERVIEW · Seen Jun 2024
- Run-Length EncodingONSITE INTERVIEW · Seen Jun 2024
- Rate Limiter with Hourly and Daily Effort QuotasPHONE SCREEN · Seen Jul 2026
- Merging PalindromesPHONE SCREEN · Seen Sep 2024
- Find the Element With Odd FrequencyPHONE SCREEN · Seen Jun 2024
- Merge IntervalsPHONE SCREEN · Seen Jun 2024
- Sum of Divisors of the Array GCDPHONE SCREEN · Seen Jun 2024
- How Many Sentences? 🌿OA · Seen Mar 2024
Similar questions at other companies
- Generate One-Two Strings with Sum NGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Count Digit Replacements with No Equal Adjacent DigitsMicrosoft · OAMicrosoft interview questions
- Replace '?' to Avoid Adjacent DuplicatesSalesforce · OASalesforce interview questions
- Count Equal-Frequency SubsequencesExpedia · OAExpedia interview questions
- Maximum Bouquet ValueOracle · ONSITE INTERVIEWOracle interview questions
- Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
- Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Decode Numeric StringArcesium · ONSITE INTERVIEWArcesium interview questions