Print all Substrings of a String that has equal number of vowels and consonants in C/C++
In this lesson, we'll look at how to display all substrings of a string that have the same number of vowels and consonants in C and C++.
Provided a string S, the goal is to show all the substrings of that string that have an equal amount of vowels and consonants.
The basic technique to overcoming this challenge is to produce all the substrings and then count the number of vowels and consonants in each substring. If they are the same, print it.
Time complexity will be O(N^3).
Auxiliary Space will be O(1).
Reliable Strategy: To find the solution, use the following concept:
In this method, we use two loops to keep the start and end indices of each substring in a vector with an equal amount of vowels and consonants.
This method includes the following steps:
The following is the code for the aforementioned method:
po poli police ol olic li lice ic ce
Time Complexity will be O(N2).
Auxiliary Space will be O(N).
Next TopicAccumulator in C++