codeparrot/xlcost-text-to-code huggingface dataset:
Find the number of players who roll the dice when the dice output sequence is given | C # implementation of the approach ; Function to return the number of players ; Initialize cnt as 0 ; Iterate in the string ; Check for numbers other than x ; Driver code
using System ; class GFG { static int findM ( String s , int x ) { int cnt = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] - '0' != x ) cnt ++ ; } return cnt ; } public static void Main ( ) { String s = "3662123" ; int x = 6 ; Console . Write ( findM ( s , x ) ) ; } }
Print the first and last character of each word in a String | C # program to print the first and last character of each word in a String ; Function to print the first and last character of each word . ; If it is the first word of the string then print it . ; If it is the last word of the string then also print it . ; If there is a space print the successor and predecessor to space . ; Driver code
using System ; class GFG { static void FirstAndLast ( string str ) { int i ; for ( i = 0 ; i < str . Length ; i ++ ) { if ( i == 0 ) Console . Write ( str [ i ] ) ; if ( i == str . Length - 1 ) Console . Write ( str [ i ] ) ; if ( str [ i ] == ' ▁ ' ) { Console . Write ( str [ i - 1 ] + " ▁ " + str [ i + 1 ] ) ; } } } public static void Main ( ) { string str = " Geeks ▁ for ▁ Geeks " ; FirstAndLast ( str ) ; } }
Find the longest sub | C # implementation of the approach ; Function to find longest prefix suffix ; To store longest prefix suffix ; Length of the previous longest prefix suffix ; lps [ 0 ] is always 0 ; Loop calculates lps [ i ] for i = 1 to n - 1 ; ( pat [ i ] != pat [ len ] ) ; If len = 0 ; Function to find the longest substring which is prefix as well as a sub - string of s [ 1. . . n - 2 ] ; Find longest prefix suffix ; If lps of n - 1 is zero ; At any position lps [ i ] equals to lps [ n - 1 ] ; If answer is not possible ; Driver code ; function call
using System ; class GFG { static int [ ] compute_lps ( string s ) { int n = s . Length ; int [ ] lps = new int [ n ] ; int len = 0 ; lps [ 0 ] = 0 ; int i = 1 ; while ( i < n ) { if ( s [ i ] == s [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) len = lps [ len - 1 ] ; else { lps [ i ] = 0 ; i ++ ; } } } return lps ; } static void Longestsubstring ( string s ) { int [ ] lps = compute_lps ( s ) ; int n = s . Length ; if ( lps [ n - 1 ] == 0 ) { Console . WriteLine ( - 1 ) ; return ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( lps [ i ] == lps [ n - 1 ] ) { Console . WriteLine ( s . Substring ( 0 , lps [ i ] ) ) ; return ; } } if ( lps [ lps [ n - 1 ] - 1 ] == 0 ) Console . WriteLine ( - 1 ) ; else Console . WriteLine ( s . Substring ( 0 , lps [ lps [ n - 1 ] - 1 ] ) ) ; } public static void Main ( ) { string s = " fixprefixsuffix " ; Longestsubstring ( s ) ; } }
Pairs of strings which on concatenating contains each character of " string " | C # implementation of the above approach ; Function to return the bitmask for the string ; Function to return the count of pairs ; bitMask [ i ] will store the count of strings from the array whose bitmask is i ; To store the count of pairs ; MAX - 1 = 63 i . e . 111111 in binary ; arr [ i ] cannot make s pair with itself i . e . ( arr [ i ] , arr [ i ] ) ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int MAX = 64 ; static int getBitmask ( char [ ] s ) { int temp = 0 ; for ( int j = 0 ; j < s . Length ; j ++ ) { switch ( s [ j ] ) { case ' s ' : temp = temp | ( 1 ) ; break ; case ' t ' : temp = temp | ( 2 ) ; break ; case ' r ' : temp = temp | ( 4 ) ; break ; case ' i ' : temp = temp | ( 8 ) ; break ; case ' n ' : temp = temp | ( 16 ) ; break ; case ' g ' : temp = temp | ( 32 ) ; break ; default : break ; } } return temp ; } static int countPairs ( String [ ] arr , int n ) { int [ ] bitMask = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) bitMask [ getBitmask ( arr [ i ] . ToCharArray ( ) ) ] ++ ; int cnt = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = i ; j < MAX ; j ++ ) { if ( ( i j ) == ( MAX - 1 ) ) { if ( i == j ) cnt += ( ( bitMask [ i ] * bitMask [ i ] - 1 ) / 2 ) ; else cnt += ( bitMask [ i ] * bitMask [ j ] ) ; } } } return cnt ; } public static void Main ( String [ ] args ) { String [ ] arr = { " strrr " , " string " , " gstrin " } ; int n = arr . Length ; Console . WriteLine ( countPairs ( arr , n ) ) ; } }
Find the count of sub | C # implementation of the approach ; Function to return the count of required occurrence ; To store the count of occurrences ; Check first four characters from ith position ; Variables for counting the required characters ; Check the four contiguous characters which can be reordered to form ' clap ' ; If all four contiguous characters are present then increment cnt variable ; Driver code
using System ; class GFG { static int countOcc ( string s ) { int cnt = 0 ; for ( int i = 0 ; i < s . Length - 3 ; i ++ ) { int c = 0 , l = 0 , a = 0 , p = 0 ; for ( int j = i ; j < i + 4 ; j ++ ) { switch ( s [ j ] ) { case ' c ' : c ++ ; break ; case ' l ' : l ++ ; break ; case ' a ' : a ++ ; break ; case ' p ' : p ++ ; break ; } } if ( c == 1 && l == 1 && a == 1 && p == 1 ) cnt ++ ; } return cnt ; } public static void Main ( ) { string s = " clapc " ; Console . Write ( countOcc ( s . ToLower ( ) ) ) ; } }
Number of ways in which the substring in range [ L , R ] can be formed using characters out of the range | C # implementation of the approach ; Function to return the number of ways to form the sub - string ; Initialize a hash - table with 0 ; Iterate in the string and count the frequency of characters that do not lie in the range L and R ; Out of range characters ; Stores the final number of ways ; Iterate for the sub - string in the range L and R ; If exists then multiply the number of ways and decrement the frequency ; If does not exist the sub - string cannot be formed ; Return the answer ; Driver code
using System ; class GfG { static int calculateWays ( String s , int n , int l , int r ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < l i > r ) freq [ s [ i ] - ' a ' ] ++ ; } int ways = 1 ; for ( int i = l ; i <= r ; i ++ ) { if ( freq [ s [ i ] - ' a ' ] != 0 ) { ways = ways * freq [ s [ i ] - ' a ' ] ; freq [ s [ i ] - ' a ' ] -- ; } else { ways = 0 ; break ; } } return ways ; } public static void Main ( ) { String s = " cabcaab " ; int n = s . Length ; int l = 1 , r = 3 ; Console . WriteLine ( calculateWays ( s , n , l , r ) ) ; } }
Program to find the kth character after decrypting a string | C # implementation of the approach ; Function to print kth character of String s after decrypting it ; Get the length of string ; Initialise pointer to character of input string to zero ; Total length of resultant string ; Traverse the string from starting and check if each character is alphabet then increment total_len ; If total_leg equal to k then return string else increment i ; Parse the number ; Update next_total_len ; Get the position of kth character ; Position not found then update position with total_len ; Recursively find the kth position ; Else update total_len by next_total_len ; Return - 1 if character not found ; Driver code
using System ; class GFG { static char findKthChar ( String s , int k ) { int len = s . Length ; int i = 0 ; int total_len = 0 ; while ( i < len ) { if ( char . IsLetter ( s [ i ] ) ) { total_len ++ ; if ( total_len == k ) return s [ i ] ; i ++ ; } else { int n = 0 ; while ( i < len && ! char . IsLetter ( s [ i ] ) ) { n = n * 10 + ( s [ i ] - '0' ) ; i ++ ; } int next_total_len = total_len * n ; if ( k <= next_total_len ) { int pos = k % total_len ; if ( pos == 0 ) { pos = total_len ; } return findKthChar ( s , pos ) ; } else { total_len = next_total_len ; } } } return ' ▁ ' ; } public static void Main ( String [ ] args ) { String s = " ab2c3" ; int k = 5 ; Console . WriteLine ( findKthChar ( s , k ) ) ; } }
Check whether the Average Character of the String is present or not | C # program to check if the average character is present in the string or not ; Checks if the character is present ; Get the length of string ; Iterate from i = 0 to the length of the string to check if the character is present in the string ; Finds the average character of the string ; Calculate the sum of ASCII values of each character ; Calculate the average of ASCII values ; Convert the ASCII value to character and return it ; Driver code ; Get the average character ; Check if the average character is present in string or not
using System ; class GFG { static bool check_char ( string st , char ch ) { int l = st . Length ; for ( int i = 0 ; i < l ; i ++ ) { if ( st [ i ] == ch ) return true ; } return false ; } static char find_avg ( string st ) { int i , sm = 0 ; int l = st . Length ; char ch ; for ( i = 0 ; i < l ; i ++ ) { ch = st [ i ] ; sm = sm + ( int ) ( ch ) ; } int avg = ( int ) ( Math . Floor ( ( double ) ( sm / l ) ) ) ; return ( ( char ) ( avg ) ) ; } public static void Main ( ) { string st = " ag23sdfa " ; char ch = find_avg ( st ) ; Console . WriteLine ( ch ) ; if ( check_char ( st , ch ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Convert the ASCII value sentence to its equivalent string | C # implementation of the approach ; Function to print the character sequence for the given ASCII sentence ; Append the current digit ; If num is within the required range ; Convert num to char ; Reset num to 0 ; Driver code
using System ; class GFG { static void asciiToSentence ( String str , int len ) { int num = 0 ; for ( int i = 0 ; i < len ; i ++ ) { num = num * 10 + ( str [ i ] - '0' ) ; if ( num >= 32 && num <= 122 ) { char ch = ( char ) num ; Console . Write ( ch ) ; num = 0 ; } } } public static void Main ( ) { String str = "7110110110711510211111471101101107115" ; int len = str . Length ; asciiToSentence ( str , len ) ; } }
Distinct state codes that appear in a string as contiguous sub | C # implementation of the above approach . ; Function to return the count of distinct state codes ; Insert every sub - String of length 2 in the set ; Return the size of the set ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int countDistinctCode ( String str ) { HashSet < String > codes = new HashSet < String > ( ) ; for ( int i = 0 ; i < str . Length - 1 ; i ++ ) codes . Add ( str . Substring ( i , 2 ) ) ; return codes . Count ; } public static void Main ( String [ ] args ) { String str = " UPUP " ; Console . Write ( countDistinctCode ( str ) ) ; } }
Count of buttons pressed in a keypad mobile | C # implementation of the approach ; Array to store how many times a button has to be pressed for typing a particular character ; Function to return the count of buttons pressed to type the given string ; Count the key presses ; Return the required count ; Driver code
using System ; class GFG { static readonly int [ ] arr = { 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 4 , 1 , 2 , 3 , 1 , 2 , 3 , 4 } ; public static int countKeyPressed ( String str , int len ) { int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) count = count + arr [ str [ i ] - ' a ' ] ; return count ; } public static void Main ( ) { String str = " abcdef " ; int len = str . Length ; Console . Write ( countKeyPressed ( str , len ) ) ; } }
First string from the given array whose reverse is also present in the same array | C # implementation of the approach ; Function that returns true if s1 is equal to reverse of s2 ; If both the strings differ in length ; In case of any character mismatch ; Function to return the first word whose reverse is also present in the array ; Check every string ; Pair with every other string appearing after the current string ; If first string is equal to the reverse of the second string ; No such string exists ; Driver code
using System ; class GFG { static bool isReverseEqual ( String s1 , String s2 ) { if ( s1 . Length != s2 . Length ) return false ; int len = s1 . Length ; for ( int i = 0 ; i < len ; i ++ ) if ( s1 [ i ] != s2 [ len - i - 1 ] ) return false ; return true ; } static String getWord ( String [ ] str , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( isReverseEqual ( str [ i ] , str [ j ] ) ) return str [ i ] ; return " - 1" ; } public static void Main ( String [ ] args ) { String [ ] str = { " geeks " , " for " , " skeeg " } ; int n = str . Length ; Console . Write ( getWord ( str , n ) ) ; } }
Check if the given string is K | C # implementation of the approach ; Function that return true if sub - string of length k starting at index i is also a prefix of the string ; k length sub - string cannot start at index i ; Character mismatch between the prefix and the sub - string starting at index i ; Function that returns true if str is K - periodic ; Check whether all the sub - strings str [ 0 , k - 1 ] , str [ k , 2 k - 1 ] ... are equal to the k length prefix of the string ; Driver code
using System ; class GFG { static bool isPrefix ( String str , int len , int i , int k ) { if ( i + k > len ) return false ; for ( int j = 0 ; j < k ; j ++ ) { if ( str [ i ] != str [ j ] ) return false ; i ++ ; } return true ; } static bool isKPeriodic ( String str , int len , int k ) { for ( int i = k ; i < len ; i += k ) if ( ! isPrefix ( str , len , i , k ) ) return false ; return true ; } public static void Main ( ) { String str = " geeksgeeks " ; int len = str . Length ; int k = 5 ; if ( isKPeriodic ( str , len , k ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Minimum number of letters needed to make a total of n | C # implementation of the approach ; Function to return the minimum letters required to make a total of n ; Driver code
using System ; class GFG { static int minLettersNeeded ( int n ) { if ( n % 26 == 0 ) return ( n / 26 ) ; else return ( ( n / 26 ) + 1 ) ; } public static void Main ( ) { int n = 52 ; Console . Write ( minLettersNeeded ( n ) ) ; } }
Find the first maximum length even word from a string | C # program to find maximum length even word ; Function to find maximum length even word ; To store length of current word . ; To store length of maximum length word . ; To store starting index of maximum length word . ; If current character is space then word has ended . Check if it is even length word or not . If yes then compare length with maximum length found so far . ; Set currlen to zero for next word . ; Update length of current word . ; Check length of last word . ; If no even length word is present then return - 1. ; Driver code
using System ; class GFG { static String findMaxLenEven ( string str ) { int n = str . Length ; int i = 0 ; int currlen = 0 ; int maxlen = 0 ; int st = - 1 ; while ( i < n ) { if ( str [ i ] == ' ▁ ' ) { if ( currlen % 2 == 0 ) { if ( maxlen < currlen ) { maxlen = currlen ; st = i - currlen ; } } currlen = 0 ; } else { currlen ++ ; } i ++ ; } if ( currlen % 2 == 0 ) { if ( maxlen < currlen ) { maxlen = currlen ; st = i - currlen ; } } if ( st == - 1 ) return " - 1" ; return str . Substring ( st , maxlen ) ; } public static void Main ( ) { string str = " this ▁ is ▁ a ▁ test ▁ string " ; Console . WriteLine ( findMaxLenEven ( str ) ) ; } }
Minimum length substring with exactly K distinct characters | C # program to find minimum length subString having exactly k distinct character . ; Function to find minimum length subString having exactly k distinct character . ; Starting index of sliding window . ; Ending index of sliding window . ; To store count of character . ; To store count of distinct character in current sliding window . ; To store length of current sliding window . ; To store minimum length . ; To store starting index of minimum length subString . ; Increment count of current character If this count is one then a new distinct character is found in sliding window . ; If number of distinct characters is is greater than k , then move starting point of sliding window forward , until count is k . ; Remove characters from the beginning of sliding window having count more than 1 to minimize length . ; Compare length with minimum length and update if required . ; Return minimum length subString . ; Driver code
using System ; class GFG { static String findMinLenStr ( string str , int k ) { int n = str . Length ; int st = 0 ; int end = 0 ; int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) cnt [ i ] = 0 ; int distEle = 0 ; int currlen ; int minlen = n ; int startInd = - 1 ; while ( end < n ) { cnt [ str [ end ] - ' a ' ] ++ ; if ( cnt [ str [ end ] - ' a ' ] == 1 ) distEle ++ ; if ( distEle > k ) { while ( st < end && distEle > k ) { if ( cnt [ str [ st ] - ' a ' ] == 1 ) distEle -- ; cnt [ str [ st ] - ' a ' ] -- ; st ++ ; } } if ( distEle == k ) { while ( st < end && cnt [ str [ st ] - ' a ' ] > 1 ) { cnt [ str [ st ] - ' a ' ] -- ; st ++ ; } currlen = end - st + 1 ; if ( currlen < minlen ) { minlen = currlen ; startInd = st ; } } end ++ ; } return str . Substring ( startInd , minlen ) ; } public static void Main ( ) { string str = " efecfefd " ; int k = 4 ; Console . WriteLine ( findMinLenStr ( str , k ) ) ; } }
Minimum number of replacements to make the binary string alternating | Set 2 | C # implementation of the approach ; Function to return the minimum number of characters of the given binary string to be replaced to make the string alternating ; If there is 1 at even index positions ; If there is 0 at odd index positions ; Driver code
using System ; class GFG { static int minReplacement ( String s , int len ) { int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( i % 2 == 0 && s [ i ] == '1' ) ans ++ ; if ( i % 2 == 1 && s [ i ] == '0' ) ans ++ ; } return Math . Min ( ans , len - ans ) ; } public static void Main ( String [ ] args ) { String s = "1100" ; int len = s . Length ; Console . Write ( minReplacement ( s , len ) ) ; } }
Deletions of "01" or "10" in binary string to make it free from "01" or "10" | C # implementation of the approach ; Function to return the count of deletions of sub - strings "01" or "10" ; To store the count of 0 s and 1 s ; Driver code
using System ; class GFG { static int substrDeletion ( string str , int len ) { int count0 = 0 , count1 = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) count0 ++ ; else count1 ++ ; } return Math . Min ( count0 , count1 ) ; } public static void Main ( ) { string str = "010" ; int len = str . Length ; Console . Write ( substrDeletion ( str , len ) ) ; } }
Group consecutive characters of same type in a string | C # implementation of the approach ; Function to return the modified String ; Store original String ; Remove all white spaces ; To store the resultant String ; Traverse the String ; Group upper case characters ; Group numeric characters ; Group arithmetic operators ; Return the resultant String ; Driver code
using System ; class GFG { static String groupCharacters ( char [ ] s , int len ) { string temp = " " ; for ( int j = 0 ; j < len ; j ++ ) if ( s [ j ] != ' ▁ ' ) temp = temp + s [ j ] ; len = temp . Length ; string ans = " " ; int i = 0 ; while ( i < len ) { if ( temp [ i ] >= ( ' A ' ) && temp [ i ] <= ( ' Z ' ) ) { while ( i < len && temp [ i ] >= ( ' A ' ) && temp [ i ] <= ( ' Z ' ) ) { ans = ans + temp [ i ] ; i ++ ; } ans = ans + " ▁ " ; } else if ( temp [ i ] >= ( '0' ) && temp [ i ] <= ( '9' ) ) { while ( i < len && temp [ i ] >= ( '0' ) && temp [ i ] <= ( '9' ) ) { ans = ans + temp [ i ] ; i ++ ; } ans = ans + " ▁ " ; } else { while ( i < len && temp [ i ] >= ( ' * ' ) && temp [ i ] <= ( ' / ' ) ) { ans = ans + temp [ i ] ; i ++ ; } ans = ans + " ▁ " ; } } return ans ; } public static void Main ( ) { string s = "34FTG234 + ▁ + - ▁ * " ; int len = s . Length ; Console . WriteLine ( groupCharacters ( s . ToCharArray ( ) , len ) ) ; } }
Find the minimum number of preprocess moves required to make two strings equal | C # implementation of the approach ; Function to return the minimum number of pre - processing moves required on string A ; Length of the given strings ; To store the required answer ; Run a loop upto n / 2 ; To store frequency of 4 characters ; If size is 4 ; If size is 3 ; If size is 2 ; If n is odd ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int Preprocess ( string A , string B ) { int n = A . Length ; int ans = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; if ( mp . ContainsKey ( A [ i ] ) ) mp [ A [ i ] ] ++ ; else mp [ A [ i ] ] = 1 ; if ( mp . ContainsKey ( A [ n - i - 1 ] ) ) mp [ A [ n - i - 1 ] ] ++ ; else mp [ A [ n - i - 1 ] ] = 1 ; if ( mp . ContainsKey ( B [ i ] ) ) mp [ B [ i ] ] ++ ; else mp [ B [ i ] ] = 1 ; if ( mp . ContainsKey ( B [ n - i - 1 ] ) ) mp [ B [ n - i - 1 ] ] ++ ; else mp [ B [ n - i - 1 ] ] = 1 ; int sz = mp . Count ; if ( sz == 4 ) ans += 2 ; else if ( sz == 3 ) ans += 1 + ( A [ i ] == A [ n - i - 1 ] ? 1 : 0 ) ; else if ( sz == 2 ) ans += mp [ A [ i ] ] != 2 ? 1 : 0 ; } if ( n % 2 == 1 && A [ n / 2 ] != B [ n / 2 ] ) ans ++ ; return ans ; } public static void Main ( ) { string A = " abacaba " , B = " bacabaa " ; Console . WriteLine ( Preprocess ( A , B ) ) ; } }
Check whether two strings are equivalent or not according to given condition | C # Program to find whether two strings are equivalent or not according to given condition ; This function returns the least lexicogr - aphical String obtained from its two halves ; Base Case - If String size is 1 ; Divide the String into its two halves ; Form least lexicographical String ; Driver Code
using System ; class GFG { static String leastLexiString ( String s ) { if ( s . Length == 1 ) return s ; String x = leastLexiString ( s . Substring ( 0 , s . Length / 2 ) ) ; String y = leastLexiString ( s . Substring ( s . Length / 2 ) ) ; return ( ( x + y ) . CompareTo ( y + x ) . ToString ( ) ) ; } static Boolean areEquivalent ( String a , String b ) { return ! ( leastLexiString ( a ) . Equals ( leastLexiString ( b ) ) ) ; } public static void Main ( String [ ] args ) { String a = " aaba " ; String b = " abaa " ; if ( areEquivalent ( a , b ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; a = " aabb " ; b = " abab " ; if ( areEquivalent ( a , b ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }
Check if a string can be converted to another string by replacing vowels and consonants | C # program to check if a string can be converted to other string by replacing vowels and consonants ; Function to check if the character is vowel or not ; Function that checks if a string can be converted to another string ; Find length of string ; If length is not same ; Iterate for every character ; If both vowel ; Both are consonants ; Driver Code
using System ; class GfG { static bool isVowel ( char c ) { if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) return true ; return false ; } static bool checkPossibility ( string s1 , string s2 ) { int l1 = s1 . Length ; int l2 = s2 . Length ; if ( l1 != l2 ) return false ; for ( int i = 0 ; i < l1 ; i ++ ) { if ( isVowel ( s1 [ i ] ) && isVowel ( s2 [ i ] ) ) continue ; else if ( ! ( isVowel ( s1 [ i ] ) ) && ! ( isVowel ( s2 [ i ] ) ) ) continue ; else return false ; } return true ; } public static void Main ( ) { string S1 = " abcgle " ; string S2 = " ezggli " ; if ( checkPossibility ( S1 , S2 ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }