Strings: Void Int For Int
Strings: Void Int For Int
2. NO OF VOWEL IN STRING
Given a string, count the total number of vowels (a, e, i, o, u) in it. There are two
methods to count total number of vowels in a string.
Examples:
Input : abc de
Output : 2
1. Iterative
8. REMOVE VOWELS
Input : welcome to geeksforgeeks
Output : wlcm t gksfrgks
Input : what is your name ?
Output : wht s yr nm ?
1 string remVowel(string str)
2{
3 regex r("[aeiouAEIOU]");
4
5 return regex_replace(str, r, "");
6}
7
9. MINIMUM PARENTHESIS
Given a string S of parentheses ‘(‘ or ‘)’ where, 0\leq len(S)\leq 1000 . The task is to
find a minimum number of parentheses ‘(‘ or ‘)’ (at any positions) we must add to
make the resulting parentheses string is valid.
Examples:
10.GENERATE SUBSTRING
Input : abcd
Output : a
b
c
d
ab
bc
cd
abc
bcd
abcd
1 void subString(char str[], int n)
2{
3 // Pick starting point
4 for (int len = 1; len <= n; len++)
5 {
6 // Pick ending point
7 for (int i = 0; i <= n - len; i++)
8 {
9 // Print characters from current
10 // starting point to current ending
11 // point.
12 int j = i + len - 1;
13 for (int k = i; k <= j; k++)
14 cout << str[k];
15
16 cout << endl;
17 }
18 }
19 }