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. Examples: 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: C++ Program: Output 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++ |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India