FastPrepCount Vowel Permutations
Problems/Count Vowel Permutations

Count Vowel Permutations

Zscaler logoZscaler● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report keeps the goal of counting vowel strings and two sample cues about which vowels can sit next to each other. It leaves out the remaining transitions, the modulo, the interface, and the limits. Our version uses one usual complete set of transitions and is about 42% the same as the reported question.

Return the number of length-n strings made only from a, e, i, o, and u that follow these rules:

  • a may be followed only by e.
  • e may be followed only by a or i.
  • i may be followed by a, e, o, or u.
  • o may be followed only by i or u.
  • u may be followed only by a.

Return the count modulo 1,000,000,007.

Function

countVowelPermutations(n: int) → int

Examples

Example 1

n = 1return = 5

Every single vowel is valid.

Example 2

n = 2return = 10

The valid transitions are ae, ea, ei, ia, ie, io, iu, oi, ou, ua.

Example 3

n = 5return = 68

Dynamic 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

Interview reports that mention this question

  • Zscaler SDE C++ and OS Rounds: 7 Experiences (Part 2 of 6)
  • Zscaler Campus SDE Interviews: 37 Experiences (Part 1 of 6)

Zscaler interview experiences

  • Zscaler Campus Drive Interviews: 4 Experiences (Part 6 of 6)
  • Zscaler Java, QA and Cloud Rounds: 8 Experiences (Part 5 of 6)
  • Zscaler UI and DevTest Rounds: 8 Experiences (Part 4 of 6)
  • Zscaler Intern, QA and SRE Rounds: 7 Experiences (Part 3 of 6)
All Zscaler interview questionsSee Zscaler hiring insights
Saved
class Solution {
    public int countVowelPermutations(int n) {
      // write your code here
    }
}
Checking account…