Grokking Amazon Coding Interview
Ask Author
Back to course home

0% completed

Solution: Count Vowels Permutation
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given a positive integer n, return the number of strings of length n can be formed by following rules:

  • Each character of the string should be only a lowercase vowel ('a', 'e', 'i', 'o', 'u').
  • The vowel 'a' is only allowed to be followed by the vowel 'e'.
  • The vowel 'e' can be followed by either 'a' or 'i'.
  • The vowel 'i' cannot be followed by another 'i'.
  • The vowel 'o' can be followed by either 'i' or 'u'.
  • The vowel 'u' must be followed by 'a'.

Return the answer modulo 10^9 + 7, as it could be very large.

Examples

Example 1:

  • Input: `n = 1

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible