Vowel and Consonant Substrings | InterviewBit | Solution

Problem Link.

class Solution:
    def solve(self, A):
        vowels = ['a', 'e', 'i', 'o', 'u']
        data = {'c': 0, 'v': 0}

        ans = 0
        for c in A:
            if c in vowels:
                ans += data['c']
                data['v'] += 1
            else:
                ans += data['v']
                data['c'] += 1
            ans = ans % (10**9 + 7)

        return (ans % (10**9 + 7))
Avatar for Tanishq Chaudhary

Producing high-quality intuitive explanations of interview problems. Currently covering LeetCode and InterviewBit.

    Comments

    1. Please write the proof.

    2. This solution need an amendment for 2 digit number.

    3. Please write a Proof for this

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.