codeparrot/xlcost-text-to-code huggingface dataset:
Longest palindromic string possible by concatenating strings from a given array | C # program for the above approach ; Stores the distinct Strings from the given array ; Insert the Strings into set ; Stores the left and right subStrings of the given String ; Stores the middle subString ; Traverse the array of Strings ; Reverse the current String ; Checking if the String is itself a palindrome or not ; Check if the reverse of the String is present or not ; Append to the left subString ; Append to the right subString ; Erase both the Strings from the set ; Print the left subString ; Print the middle subString ; Print the right subString ; Driver Code ; Function Call
using System ; using System . Collections . Generic ; class GFG { static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } static void max_len ( String [ ] s , int N , int M ) { HashSet < String > set_str = new HashSet < String > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { set_str . Add ( s [ i ] ) ; } List < String > left_ans = new List < String > ( ) ; List < String > right_ans = new List < String > ( ) ; String mid = " " ; for ( int i = 0 ; i < N ; i ++ ) { String t = s [ i ] ; t = reverse ( t ) ; if ( t == s [ i ] ) { mid = t ; } else if ( set_str . Contains ( t ) ) { left_ans . Add ( s [ i ] ) ; right_ans . Add ( t ) ; set_str . Remove ( s [ i ] ) ; set_str . Remove ( t ) ; } } foreach ( String x in left_ans ) { Console . Write ( x ) ; } Console . Write ( mid ) ; right_ans . Reverse ( ) ; foreach ( String x in right_ans ) { Console . Write ( x ) ; } } public static void Main ( String [ ] args ) { int N = 4 , M = 3 ; String [ ] s = { " omg " , " bbb " , " ffd " , " gmo " } ; max_len ( s , N , M ) ; } }
Minimize steps defined by a string required to reach the destination from a given source | C # program for the above approach ; Function to find the minimum length of string required to reach from source to destination ; Size of the string ; Stores the index of the four directions E , W , N , S ; If destination reached ; Iterate over the string ; Move east ; Change x1 according to direction E ; Move west ; Change x1 according to direction W ; Move north ; Change y1 according to direction N ; Move south ; Change y1 according to direction S ; Store the max of all positions ; Print the minimum length of string required ; Otherwise , it is impossible ; Driver Code ; Given string ; Given source and destination ; Function call
using System ; class GFG { static void minimum_length ( int x1 , int y1 , int x2 , int y2 , string str ) { int n = str . Length ; int pos1 , pos2 , pos3 , pos4 ; pos1 = - 1 ; pos2 = - 1 ; pos3 = - 1 ; pos4 = - 1 ; if ( x1 == x2 && y1 == y2 ) { Console . WriteLine ( "0" ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( x2 > x1 ) { if ( str [ i ] == ' E ' ) { x1 = x1 + 1 ; if ( x1 == x2 ) { pos1 = i ; } } } if ( x2 < x1 ) { if ( str [ i ] == ' W ' ) { x1 = x1 - 1 ; if ( x1 == x2 ) { pos2 = i ; } } } if ( y2 > y1 ) { if ( str [ i ] == ' N ' ) { y1 = y1 + 1 ; if ( y1 == y2 ) { pos3 = i ; } } } if ( y2 < y1 ) { if ( str [ i ] == ' S ' ) { y1 = y1 - 1 ; if ( y1 == y2 ) { pos4 = i ; } } } } int z ; z = Math . Max ( pos1 , Math . Max ( Math . Max ( pos2 , pos3 ) , pos4 ) ) ; if ( x1 == x2 && y1 == y2 ) { Console . WriteLine ( z + 1 ) ; } else { Console . WriteLine ( " - 1" ) ; } } } public static void Main ( ) { string str = " SESNW " ; int x1 = 0 , x2 = 1 , y1 = 0 , y2 = 1 ; minimum_length ( x1 , y1 , x2 , y2 , str ) ; } }
Remove all duplicate adjacent characters from a string using Stack | C # program to implement the above approach ; Function to remove adjacent duplicate elements ; Store the String without duplicate elements ; Store the index of str ; Traverse the String str ; Checks if stack is empty or top of the stack is not equal to current character ; If top element of the stack is equal to the current character ; If stack is empty ; If stack is not Empty ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static String ShortenString ( String str1 ) { Stack < char > st = new Stack < char > ( ) ; int i = 0 ; while ( i < str1 . Length ) { if ( st . Count == 0 || ( st . Count != 0 && str1 [ i ] != st . Peek ( ) ) ) { st . Push ( str1 [ i ] ) ; i ++ ; } else { if ( st . Count != 0 ) st . Pop ( ) ; i ++ ; } } if ( st . Count == 0 ) { return ( " Empty ▁ String " ) ; } else { String short_String = " " ; while ( st . Count != 0 ) { short_String = st . Peek ( ) + short_String ; st . Pop ( ) ; } return ( short_String ) ; } } public static void Main ( String [ ] args ) { String str1 = " azzxzy " ; Console . Write ( ShortenString ( str1 ) ) ; } }
Count ways to place all the characters of two given strings alternately | C # program to implement the above approach ; Function to get the factorial of N ; Function to get the total number of distinct ways ; Length of str1 ; Length of str2 ; If both strings have equal length ; If both strings do not have equal length ; Driver code
using System ; class GFG { static int fact ( int n ) { int res = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { res = res * i ; } return res ; } static int distinctWays ( string str1 , string str2 ) { int n = str1 . Length ; int m = str2 . Length ; if ( n == m ) { return 2 * fact ( n ) * fact ( m ) ; } return fact ( n ) * fact ( m ) ; } public static void Main ( ) { string str1 = " aegh " ; string str2 = " rsw " ; Console . Write ( distinctWays ( str1 , str2 ) ) ; } }
Smallest string without any multiplication sign that represents the product of two given numbers | C # program for the above approach ; Function to find the string which evaluates to the product of A and B ; Stores the result ; 2 ^ log <= B && 2 ^ ( log + 1 ) > B ; Update res to res += A X 2 ^ log ; Update res to res += A X 2 ^ 0 ; Find the remainder ; If remainder is not equal to 0 ; Return the resultant string ; Function to find the minimum length representation of A * B ; Find representation of form A << k1 + A << k2 + ... + A << kn ; Find representation of form B << k1 + B << k2 + ... + B << kn ; Compare the length of the representations ; Driver Code ; Product A X B ; Function call
using System ; class GFG { public static string len ( long A , long B ) { string res = " " ; long log = 0 ; do { log = ( long ) ( Math . Log ( B ) / Math . Log ( 2 ) ) ; if ( log != 0 ) { res += A + " < < " + log ; } else { res += A ; break ; } B = B - ( long ) Math . Pow ( 2 , log ) ; if ( B != 0 ) { res += " + " ; } else break ; } while ( log != 0 ) ; return res ; } public static void minimumString ( long A , long B ) { string res1 = len ( A , B ) ; string res2 = len ( B , A ) ; if ( res1 . Length > res2 . Length ) { Console . WriteLine ( res2 ) ; } else { Console . WriteLine ( res1 ) ; } } public static void Main ( ) { long A = 6 ; long B = 10 ; minimumString ( A , B ) ; } }
Count substrings of a given string whose anagram is a palindrome | C # program for the above approach ; Function to print count of subStrings whose anagrams are palindromic ; Stores the answer ; Iterate over the String ; Set the current character ; Parity update ; Print the readonly count ; Driver Code ; Function Call
using System ; class GFG { static void countSubString ( String s ) { int res = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { int x = 0 ; for ( int j = i ; j < s . Length ; j ++ ) { int temp = 1 << s [ j ] - ' a ' ; x ^= temp ; if ( ( x & ( x - 1 ) ) == 0 ) res ++ ; } } Console . Write ( res ) ; } public static void Main ( String [ ] args ) { String str = " aaa " ; countSubString ( str ) ; } }
Count substrings of a given string whose anagram is a palindrome | C # program for the above approach ; Function to get the count of subStrings whose anagrams are palindromic ; Store the answer ; Map to store the freq of masks ; Set frequency for mask 00. . .00 to 1 ; Store mask in x from 0 to i ; Update answer ; Update frequency ; Print the answer ; Driver Code ; Function Call
using System ; using System . Collections . Generic ; class GFG { static void countSubString ( String s ) { int answer = 0 ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; m . Add ( 0 , 1 ) ; int x = 0 ; for ( int j = 0 ; j < s . Length ; j ++ ) { x ^= 1 << ( s [ j ] - ' a ' ) ; answer += m . ContainsKey ( x ) ? m [ x ] : 0 ; for ( int i = 0 ; i < 26 ; ++ i ) { answer += m . ContainsKey ( x ^ ( 1 << i ) ) ? m [ x ^ ( 1 << i ) ] : 0 ; } if ( m . ContainsKey ( x ) ) m [ x ] = m [ x ] + 1 ; else m . Add ( x , 1 ) ; } Console . Write ( answer ) ; } public static void Main ( String [ ] args ) { String str = " abab " ; countSubString ( str ) ; } }
Sum of an array of large numbers | C # program for the above approach ; Function to print the result of the summation of numbers having K - digit ; Reverse the array to obtain the result ; Print every digit of the answer ; Function to calculate the total sum ; Stores the array of large numbers in integer format ; Convert each element from character to integer ; Stores the carry ; Stores the result of summation ; Initialize the sum ; Calculate sum ; Update the sum by adding existing carry ; Store the number of digits ; Increase count of digits ; If the number exceeds 9 , Store the unit digit in carry ; Store the rest of the sum ; Append digit by digit into result array ; Append result until carry is 0 ; Print the result ; Driver Code ; Given N array of large numbers
using System ; using System . Collections . Generic ; class GFG { static void printResult ( List < int > result ) { result . Reverse ( ) ; int i = 0 ; while ( i < result . Count ) { Console . Write ( result [ i ] ) ; i ++ ; } } static void sumOfLargeNumbers ( String [ ] v , int k , int N ) { List < List < int > > x = new List < List < int > > ( 1000 ) ; for ( int i = 0 ; i < k ; i ++ ) x . Add ( new List < int > ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { x [ i ] . Add ( v [ i ] [ j ] - '0' ) ; } } int carry = 0 ; List < int > result = new List < int > ( ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int sum = 0 ; for ( int j = 0 ; j < k ; j ++ ) sum += x [ j ] [ i ] ; sum += carry ; int temp = sum ; int count = 0 ; while ( temp > 9 ) { temp = temp % 10 ; count ++ ; } long l = ( long ) Math . Pow ( 10 , count ) ; if ( l != 1 ) carry = ( int ) ( sum / l ) ; sum = sum % 10 ; result . Add ( sum ) ; } while ( carry != 0 ) { int a = carry % 10 ; result . Add ( a ) ; carry = carry / 10 ; } printResult ( result ) ; } public static void Main ( String [ ] args ) { int K = 10 ; int N = 5 ; String [ ] arr = { "1111111111" , "1111111111" , "1111111111" , "1111111111" , "1111111111" } ; sumOfLargeNumbers ( arr , N , K ) ; } }
Reverse words in a given string | Set 2 | C # program to implement the above approach ; Function to reverse the words of a given String ; Stack to store each word of the String ; Store the whole String in String stream ; Push each word of the String into the stack ; Print the String in reverse order of the words ; Driver Code
using System ; using System . Collections ; class GFG { static void printRev ( string str ) { Stack st = new Stack ( ) ; String [ ] separator = { " ▁ " } ; string [ ] ss = str . Split ( separator , int . MaxValue , StringSplitOptions . RemoveEmptyEntries ) ; foreach ( string temp in ss ) { st . Push ( temp ) ; } while ( st . Count > 0 ) { Console . Write ( st . Peek ( ) + " ▁ " ) ; st . Pop ( ) ; } } public static void Main ( string [ ] args ) { string str ; str = " geeks ▁ quiz ▁ practice ▁ code " ; printRev ( str ) ; } }
Count of substrings of a Binary string containing only 1 s | C # implementation to find count of substring containing only ones ; Function to find the total number of substring having only ones ; Driver code
using System ; class GFG { static int countOfSubstringWithOnlyOnes ( string s ) { int res = 0 , count = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { count = s [ i ] == '1' ? count + 1 : 0 ; res = ( res + count ) ; } return res ; } public static void Main ( string [ ] args ) { string s = "0110111" ; Console . Write ( countOfSubstringWithOnlyOnes ( s ) ) ; } }
Count of Distinct strings possible by inserting K characters in the original string | C # program for the above approach ; Function to calculate and return x ^ n in log ( n ) time using Binary Exponentiation ; Function to calculate the factorial of a number ; Function to calculate combination ; nCi = ( n ! ) / ( ( n - i ) ! * i ! ) ; Using Euler 's theorem of Modular  multiplicative inverse to find  the inverse of a number.  (1/a)%mod=a^(m?2)%mod ; Function to find the count of possible strings ; Number of ways to form all possible strings ; Number of ways to form strings that don 't contain the input  string as a subsequence ; Checking for all prefix length from 0 to | S | - 1. ; To calculate nCi ; Select the remaining characters 25 ^ ( N - i ) ; Add the answer for this prefix length to the readonly answer ; Answer is the difference of allWays and noWays ; Print the answer ; Driver code
using System ; class GFG { static readonly long mod = 1000000007 ; static long binExp ( long Base , long power ) { long x = 1 ; while ( power != 0 ) { if ( power % 2 == 1 ) x = ( ( x % mod ) * ( Base % mod ) ) % mod ; Base = ( ( Base % mod ) * ( Base % mod ) ) % mod ; power = power / 2 ; } return x ; } static long fact ( long num ) { long result = 1 ; for ( long i = 1 ; i <= num ; ++ i ) { result = ( ( result % mod ) * ( i % mod ) ) % mod ; } return result ; } static long calculate_nCi ( long N , long i ) { long nfact = fact ( N ) ; long ifact = fact ( i ) ; long dfact = fact ( N - i ) ; long inv_ifact = binExp ( ifact , mod - 2 ) ; long inv_dfact = binExp ( dfact , mod - 2 ) ; long denm = ( ( inv_ifact % mod ) * ( inv_dfact % mod ) ) % mod ; long answer = ( ( nfact % mod ) * ( denm % mod ) ) % mod ; return answer ; } static void countSubstring ( long N , long s , long k ) { long allWays = binExp ( 26 , N ) ; long noWays = 0 ; for ( long i = 0 ; i < s ; ++ i ) { long nCi = calculate_nCi ( N , i ) ; long remaining = binExp ( 25 , N - i ) ; long multiply = ( ( nCi % mod ) * ( remaining % mod ) ) % mod ; noWays = ( ( noWays % mod ) + ( multiply % mod ) ) % mod ; } long answer = ( ( allWays % mod ) - ( noWays % mod ) ) % mod ; if ( answer < 0 ) answer += mod ; Console . WriteLine ( answer ) ; } public static void Main ( String [ ] args ) { String str = " abc " ; long k = 2 ; long s = str . Length ; long N = s + k ; countSubstring ( N , s , k ) ; } }
Calculate Sum of ratio of special characters to length of substrings of the given string | C # Program to implement the above approach ; Stores frequency of special characters in the array ; Stores prefix sum ; Function to check whether a character is special or not ; If current character is special ; Otherwise ; Function to find sum of ratio of count of special characters and length of subStrings ; Calculate the prefix sum of special nodes ; Generate prefix sum array ; Calculate ratio for subString ; Driver Code ;
using System ; class GFG { static int N = 1000000 + 5 ; static int [ ] prefix = new int [ N ] ; static int [ ] sum = new int [ N ] ; static int isSpecial ( char c , char [ ] special ) { foreach ( char i in special ) if ( i == c ) return 1 ; return 0 ; } static double countRatio ( char [ ] s , char [ ] special ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i ] = ( isSpecial ( s [ i ] , special ) ) ; if ( i > 0 ) prefix [ i ] += prefix [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { sum [ i ] = prefix [ i ] ; if ( i > 0 ) sum [ i ] += sum [ i - 1 ] ; } double ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int count = sum [ n - 1 ] - ( i > 1 ? sum [ i - 2 ] : 0 ) ; count -= ( i < n ? sum [ n - i - 1 ] : 0 ) ; ans += ( double ) count / ( double ) i ; } return ans ; } public static void Main ( String [ ] args ) { String s = " abcd " ; char [ ] special = { ' b ' , ' c ' } ; double ans = countRatio ( s . ToCharArray ( ) , special ) ; Console . WriteLine ( " { 0 : F6 } " , ans ) ; } }
Minimum replacements in a string to make adjacent characters unequal | C # program to find minimum replacements in a string to make adjacent characters unequal ; Function which counts the minimum number of required operations ; n stores the length of the string s ; ans will store the required ans ; i is the current index in the string ; Move j until characters s [ i ] & s [ j ] are equal or the end of the string is reached ; diff stores the length of the substring such that all the characters are equal in it ; We need atleast diff / 2 operations for this substring ; Driver code
using System ; class GFG { static void count_minimum ( string s ) { int n = s . Length ; int ans = 0 ; int i = 0 ; while ( i < n ) { int j = i ; while ( j < n && s [ j ] == s [ i ] ) { j ++ ; } int diff = j - i ; ans += diff / 2 ; i = j ; } Console . WriteLine ( ans ) ; } static void Main ( ) { string str = " caaab " ; count_minimum ( str ) ; } }
Minimum cost to convert given string to consist of only vowels | C # program for the above approach ; Function to find the minimum cost ; Store vowels ; Loop for iteration of string ; Loop to calculate the cost ; Add minimum cost ; Driver Code ; Given string ; Function call
using System ; using System . Collections . Generic ; class GFG { static int min_cost ( string st ) { string vow = " aeiou " ; int cost = 0 ; for ( int i = 0 ; i < st . Length ; i ++ ) { List < int > costs = new List < int > ( ) ; for ( int j = 0 ; j < 5 ; j ++ ) costs . Add ( Math . Abs ( st [ i ] - vow [ j ] ) ) ; int minx = Int32 . MaxValue ; foreach ( int x in costs ) { if ( x < minx ) { minx = x ; } } cost += minx ; } return cost ; } public static void Main ( ) { string str = " abcde " ; Console . WriteLine ( min_cost ( str ) ) ; } }
Check if a given string is Even | C # program implementation of the approach ; Function to check if the string str is palindromic or not ; Pointers to iterate the string from both ends ; If characters are found to be distinct ; Return true if the string is palindromic ; Function to generate string from characters at odd indices ; Function to generate string from characters at even indices ; Functions to checks if string is Even - Odd Palindrome or not ; Generate odd indexed string ; Generate even indexed string ; Check for Palindrome ; Driver code
using System ; class GFG { static bool isPalindrome ( string str ) { int l = 0 ; int h = str . Length - 1 ; while ( h > l ) { if ( str [ l ++ ] != str [ h -- ] ) return false ; } return true ; } static string makeOddString ( string str ) { string odd = " " ; for ( int i = 1 ; i < str . Length ; i += 2 ) { odd += str [ i ] ; } return odd ; } static string makeevenString ( string str ) { string even = " " ; for ( int i = 0 ; i < str . Length ; i += 2 ) { even += str [ i ] ; } return even ; } static void checkevenOddPalindrome ( string str ) { string odd = makeOddString ( str ) ; string even = makeevenString ( str ) ; if ( isPalindrome ( odd ) && isPalindrome ( even ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } public static void Main ( ) { string str = " abzzab " ; checkevenOddPalindrome ( str ) ; } }
Check given string is oddly palindrome or not | C # program for the above approach ; Function to check if the String str is palindromic or not ; Iterate the String str from left and right pointers ; Keep comparing characters while they are same ; If they are not same then return false ; Return true if the String is palindromic ; Function to make String using odd indices of String str ; Functions checks if characters at odd index of the String forms palindrome or not ; Make odd indexed String ; Check for Palindrome ; Driver code ; Given String ; Function Call
using System ; class GFG { static bool isPalindrome ( string str ) { int l = 0 ; int h = str . Length - 1 ; while ( h > l ) { if ( str [ l ] != str [ h ] ) { return false ; } l ++ ; h -- ; } return true ; } static string makeOddString ( string str ) { string odd = " " ; for ( int i = 1 ; i < str . Length ; i += 2 ) { odd += str [ i ] ; } return odd ; } static void checkOddlyPalindrome ( string str ) { string odd = makeOddString ( str ) ; if ( isPalindrome ( odd ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static void Main ( ) { string str = " ddwfefwde " ; checkOddlyPalindrome ( str ) ; } }
Count of binary strings of given length consisting of at least one 1 | C # program to implement the above approach ; Function to return the count of Strings ; Calculate Math . Pow ( 2 , n ) ; Return Math . Pow ( 2 , n ) - 1 ; Driver Code
using System ; class GFG { static long count_Strings ( long n ) { int x = 1 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( 1 << x ) ; } return x - 1 ; } public static void Main ( String [ ] args ) { long n = 3 ; Console . Write ( count_Strings ( n ) ) ; } }
String formed with middle character of every right substring followed by left sequentially | C # implementation of the above approach ; Function to decrypt and print the new String ; If the whole String has been traversed ; To calculate middle index of the String ; Print the character at middle index ; Recursively call for right - subString ; Recursive call for left - subString ; Driver Code
using System ; class GFG { static void decrypt ( String Str , int Start , int End ) { if ( Start > End ) { return ; } int mid = ( Start + End ) >> 1 ; Console . Write ( Str [ mid ] ) ; decrypt ( Str , mid + 1 , End ) ; decrypt ( Str , Start , mid - 1 ) ; } public static void Main ( ) { int N = 4 ; String Str = " abcd " ; decrypt ( Str , 0 , N - 1 ) ; Console . Write ( " STRNEWLINE " ) ; N = 6 ; Str = " gyuitp " ; decrypt ( Str , 0 , N - 1 ) ; } }
Check whether the binary equivalent of a number ends with given string or not | C # implementation of the above approach ; Function returns true if s1 is suffix of s2 ; Function to check if binary equivalent of a number ends in "111" or not ; To store the binary number ; Count used to store exponent value ; Driver Code
using System ; using System . Collections ; class GFG { static bool isSuffix ( String s1 , String s2 ) { int n1 = s1 . Length , n2 = s2 . Length ; if ( n1 > n2 ) return false ; for ( int i = 0 ; i < n1 ; i ++ ) if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) return false ; return true ; } static bool CheckBinaryEquivalent ( int N , String str ) { int B_Number = 0 ; int cnt = 0 ; while ( N != 0 ) { int rem = N % 2 ; int c = ( int ) Math . Pow ( 10 , cnt ) ; B_Number += rem * c ; N /= 2 ; cnt ++ ; } String bin = B_Number . ToString ( ) ; return isSuffix ( str , bin ) ; } public static void Main ( String [ ] args ) { int N = 23 ; String str = "111" ; if ( CheckBinaryEquivalent ( N , str ) ) Console . WriteLine ( " Yes STRNEWLINE " ) ; else Console . WriteLine ( " No STRNEWLINE " ) ; } }
Count of substrings consisting only of vowels | C # program to count all subStrings in a String which contains only vowels ; Function to check if a character is vowel or not ; Function to check whether String contains only vowel ; Check if the character is not vowel then invalid ; Function to Count all subStrings in a String which contains only vowels ; Generate all subString of s ; If temp contains only vowels ; Increment the count ; Driver code
using System ; class GFG { static Boolean isvowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } static Boolean isvalid ( string s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! isvowel ( s [ i ] ) ) return false ; } return true ; } static int CountTotal ( string s ) { int ans = 0 ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { string temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp += s [ j ] ; if ( isvalid ( temp ) ) ans += 1 ; } } return ans ; } public static void Main ( ) { string s = " aeoibsddaaeiouudb " ; Console . Write ( ( CountTotal ( s ) ) + " STRNEWLINE " ) ; } }