Count Distinct Vowels in String

TCS NQT Coding Easy Go Ad-Free - ₹20/mo

Given a string consisting of English alphabetic characters (both uppercase and lowercase), count the number of distinct vowels present. Vowels are 'a', 'e', 'i', 'o', 'u', and the count is case-insensitive (i.e., 'A' and 'a' are considered the same vowel).

Examples:

Input: "Hello"

Output: 2

Explanation: The string "Hello" contains vowels 'e' and 'o', which are distinct, so the count is 2.

Input: "AEiou"

Output: 5

Explanation: All five vowels ('a', 'e', 'i', 'o', 'u') are present, and since the count is case-insensitive, they are all distinct, resulting in a count of 5.

Input: "bcdfg"

Output: 0

Explanation: The string contains no vowels, so the count of distinct vowels is 0.

Constraints

  • The input string contains only English alphabetic characters (uppercase or lowercase).
  • 1 <= length of string <= 1000