Debugging Balanced strings You are given a code for the following problem statement in…
- User
Debugging Balanced strings
You are given a code for the following problem statement in the solve function. However, the solution fails the test cases because there are bugs in the code. Your task is to find and fix all the bugs so that it passes all the test cases.
Statement
You are given a string S that consists ohly of lowercase English alphabets. A string is called a balanced string if it contains an equal number of unique vowels and unique consonants.
Task
Determine the number of substrings of S that are balanced strings.
Notes
In the English alphabet system, a, e, i, o, u are called vowels. and the rest of the alphabets are consonants.
A substring of a string is a sequence obtained by removing zero or more characters from either/both the front and back of the string. The substrings of string "101" are ["101" 01, 1, '10" 1. "0", "11" cannot be called the substring of "101" because it cannot be obtained by removing characters from the front of back of 101Example
Assumption
S = "ada"
Approach
The substrings of "ada" are ["a", "ad","ada", "d", "da","a")
Substring
a
Unique vowels
1
1
1
Unique consonants
0
1
1
1
1
0
Balanced String
NO
ad
YES
ada
d
YES
da
a
NO
YES
NO
Therefore, the number of substrings that are balanced strings is 3.
Function description
Complete the solve function provided in the editor. This function takes the following parameter and returns the number of substrings of S that are balanced strings themselves.
S Represents a string denoting the InputFunction description
Complete the solve function provided in the editor. This function takes the following parameter and returns the number of substrings of S that are balanced strings themselves:
•S. Represents a string denoting the input
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
• The first line contains a single integer / that denotes the number of test cases. I also denotes the number of times you have to run the solve function on a different set of inputs.
• The next 7 lines contain a string denoting S.
Output format
For each of the test cases, print an integer value in a new line representing the number of substrings of S that are balanced string themselves.#Calculating the answer for the current character for j in range(5): 1, h = max(v[j], c[j]), min(v[j+1], c[j+1]) if 1h 0: ans 1 h
- Assistant