STRM - EDITORIAL

PROBLEM LINK:

Practice Link

Author: Himanshu

DIFFICULTY:

EASY

PREREQUISITES:

Modular Exponentiation

EXPLANATION:

Replace vowels with 1 and consonants with 0. you will get a binary string. For eg hello will become 01001.

Now the problem reduces to binary to decimal conversion.

Approach for binary to decimal conversion:

16 8 4 2 1

0 1 0 0 1

n = length of string

Initialize the answer to 0.

Iterate over the string

Whenever you get 1 in the binary string you need to calculate pow(2, n-i-1) , where i is the ith index from the start and add it to the answer.

At each step whenever there is 1 in the binary string you need to compute power of 2. Since this can be very large. we compute it modulo 109+7. For this we use modular exponentiation.

COMPLEXITY:

O(nlogn)

SOLUTIONS:

Setter’s Solution