codeparrot/xlcost-text-to-code huggingface dataset:
Partition a number into two divisible parts | C # program to check if a string can be splitted into two strings such that one is divisible by ' a ' and other is divisible by ' b ' . ; Finds if it is possible to partition str into two parts such that first part is divisible by a and second part is divisible by b . ; Create an array of size len + 1 and initialize it with 0. Store remainders from left to right when divided by ' a ' ; Compute remainders from right to left when divided by ' b ' ; Find a point that can partition a number ; If split is not possible at this point ; We can split at i if one of the following two is true . a ) All characters after str [ i ] are 0 b ) String after str [ i ] is divisible by b , i . e . , str [ i + 1. . n - 1 ] is divisible by b . ; Driver code
using System ; class GFG { static void findDivision ( string str , int a , int b ) { int len = str . Length ; int [ ] lr = new int [ len + 1 ] ; lr [ 0 ] = ( ( int ) str [ 0 ] - ( int ) '0' ) % a ; for ( int i = 1 ; i < len ; i ++ ) lr [ i ] = ( ( lr [ i - 1 ] * 10 ) % a + ( ( int ) str [ i ] - ( int ) '0' ) ) % a ; int [ ] rl = new int [ len + 1 ] ; rl [ len - 1 ] = ( ( int ) str [ len - 1 ] - ( int ) '0' ) % b ; int power10 = 10 ; for ( int i = len - 2 ; i >= 0 ; i -- ) { rl [ i ] = ( rl [ i + 1 ] + ( ( int ) str [ i ] - ( int ) '0' ) * power10 ) % b ; power10 = ( power10 * 10 ) % b ; } for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( lr [ i ] != 0 ) continue ; if ( rl [ i + 1 ] == 0 ) { Console . WriteLine ( " YES " ) ; for ( int k = 0 ; k <= i ; k ++ ) Console . Write ( str [ k ] ) ; Console . Write ( " , ▁ " ) ; for ( int k = i + 1 ; k < len ; k ++ ) Console . Write ( str [ k ] ) ; return ; } } Console . WriteLine ( " NO " ) ; } static void Main ( ) { string str = "123" ; int a = 12 , b = 3 ; findDivision ( str , a , b ) ; } }
Efficient method for 2 's complement of a binary string | An efficient c # program to find 2 's complement ; Method to find two 's complement ; Traverse the string to get first '1' from the last of string ; If there exists no '1' concat 1 at the starting of string ; Continue traversal after the position of first '1' ; Just flip the values ; return the modified string ; Driver Code
using System ; using System . Text ; class GFG { public static string findTwoscomplement ( StringBuilder str ) { int n = str . Length ; int i ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == '1' ) { break ; } } if ( i == - 1 ) { return "1" + str ; } for ( int k = i - 1 ; k >= 0 ; k -- ) { if ( str [ k ] == '1' ) { str . Remove ( k , k + 1 - k ) . Insert ( k , "0" ) ; } else { str . Remove ( k , k + 1 - k ) . Insert ( k , "1" ) ; } } return str . ToString ( ) ; } public static void Main ( string [ ] args ) { StringBuilder str = new StringBuilder ( "00000101" ) ; Console . WriteLine ( findTwoscomplement ( str ) ) ; } }
Check length of a string is equal to the number appended at its last | C # program to check if size of string is appended at the end or not . ; Function to find if given number is equal to length or not ; Traverse string from end and find the number stored at the end . x is used to store power of 10. ; Check if number is equal to string length except that number 's digits ; Drivers code
using System ; class GFG { static bool isequal ( string str ) { int n = str . Length ; int num = 0 , x = 1 , i = n - 1 ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( '0' <= str [ i ] && str [ i ] <= '9' ) { num = ( str [ i ] - '0' ) * x + num ; x = x * 10 ; if ( num >= n ) return false ; } else break ; } return num == i + 1 ; } static public void Main ( ) { string str = " geeksforgeeks13" ; if ( isequal ( str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Check if two strings are k | C # program for the above approach ; Function to check k anagram of two strings ; First Condition : If both the strings have different length , then they cannot form anagram ; Converting str1 to Character Array arr1 ; Converting str2 to Character Array arr2 ; Sort arr1 in increasing order ; Sort arr2 in increasing order ; Iterate till str1 . length ( ) ; Condition if arr1 [ i ] is not equal to arr2 [ i ] then add it to list ; Condition to check if strings for K - anagram or not ; Driver Code ; Function Call
using System ; using System . Collections . Generic ; public class GFG { public static bool kAnagrams ( string str1 , string str2 , int k ) { int flag = 0 ; List < char > list = new List < char > ( ) ; if ( str1 . Length != str2 . Length ) { return false ; } char [ ] arr1 = str1 . ToCharArray ( ) ; char [ ] arr2 = str2 . ToCharArray ( ) ; Array . Sort ( arr1 ) ; Array . Sort ( arr2 ) ; for ( int i = 0 ; i < str1 . Length ; i ++ ) { if ( arr1 [ i ] != arr2 [ i ] ) { list . Add ( arr2 [ i ] ) ; } } if ( list . Count <= k ) flag = 1 ; if ( flag == 1 ) return true ; else return false ; } static public void Main ( ) { string str1 = " fodr " ; string str2 = " gork " ; int k = 2 ; kAnagrams ( str1 , str2 , k ) ; if ( kAnagrams ( str1 , str2 , k ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Minimum number of characters to be removed to make a binary string alternate | C # program to find minimum number of characters to be removed to make a string alternate . ; Returns count of minimum characters to be removed to make s alternate . ; if two alternating characters of string are same ; result ++ ; then need to delete a character ; Driver code
using System ; public class GFG { static int countToMake0lternate ( string s ) { int result = 0 ; for ( int i = 0 ; i < ( s . Length - 1 ) ; i ++ ) if ( s [ i ] == s [ i + 1 ] ) return result ; } static public void Main ( ) { Console . WriteLine ( countToMake0lternate ( "000111" ) ) ; Console . WriteLine ( countToMake0lternate ( "11111" ) ) ; Console . WriteLine ( countToMake0lternate ( "01010101" ) ) ; } }
Convert to a string that is repetition of a substring of k length | C # program to check if a string can be converted to a string that has repeated substrings of length k . ; Returns true if str can be converted to a string with k repeated substrings after replacing k characters . ; Length of string must be a multiple of k ; Map to store strings of length k and their counts ; If string is already a repetition of k substrings , return true . ; If number of distinct substrings is not 2 , then not possible to replace a string . ; One of the two distinct must appear exactly once . Either the first entry appears once , or it appears n / k - 1 times to make other substring appear once . ; Driver code
using System ; using System . Collections . Generic ; class GFG { static bool checkString ( String str , int k ) { int n = str . Length ; if ( n % k != 0 ) return false ; Dictionary < String , int > mp = new Dictionary < String , int > ( ) ; for ( int i = 0 ; i < n ; i += k ) { if ( ! mp . ContainsKey ( str . Substring ( i , k ) ) ) mp . Add ( str . Substring ( i , k ) , 1 ) ; else mp [ str . Substring ( i , k ) ] = mp [ str . Substring ( i , k ) ] + 1 ; } if ( mp . Count == 1 ) return true ; if ( mp . Count != 2 ) return false ; foreach ( KeyValuePair < String , int > entry in mp ) { if ( entry . Value == ( n / k - 1 ) entry . Value == 1 ) return true ; } return false ; } public static void Main ( String [ ] args ) { if ( checkString ( " abababcd " , 2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Group all occurrences of characters according to first appearance | C # program to print all occurrences of every character together . ; Since only lower case characters are there ; Method to print the string ; Initialize counts of all characters as 0 ; Count occurrences of all characters in string ; Starts traversing the string ; Print the character till its count in hash array ; Make this character 's   count value as 0. ; Driver code
using System ; class GFG { static int MAX_CHAR = 26 ; static void printGrouped ( String str ) { int n = str . Length ; int [ ] count = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) count [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { while ( count [ str [ i ] - ' a ' ] != 0 ) { Console . Write ( str [ i ] ) ; count [ str [ i ] - ' a ' ] -- ; } count [ str [ i ] - ' a ' ] = 0 ; } } public static void Main ( ) { string str = " geeksforgeeks " ; printGrouped ( str ) ; } }
Sort a string according to the order defined by another string | C # program to sort a string according to the order defined by a pattern string ; Sort str according to the order defined by pattern . ; Create a count array stor count of characters in str . ; Count number of occurrences of each character in str . ; Traverse the pattern and print every characters same number of times as it appears in str . This loop takes O ( m + n ) time where m is length of pattern and n is length of str . ; Driver code
using System ; class GFG { static int MAX_CHAR = 26 ; static void sortByPattern ( char [ ] str , char [ ] pat ) { int [ ] count = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < str . Length ; i ++ ) { count [ str [ i ] - ' a ' ] ++ ; } int index = 0 ; for ( int i = 0 ; i < pat . Length ; i ++ ) { for ( int j = 0 ; j < count [ pat [ i ] - ' a ' ] ; j ++ ) { str [ index ++ ] = pat [ i ] ; } } } public static void Main ( String [ ] args ) { char [ ] pat = " bca " . ToCharArray ( ) ; char [ ] str = " abc " . ToCharArray ( ) ; sortByPattern ( str , pat ) ; Console . WriteLine ( String . Join ( " " , str ) ) ; } }
Smallest Palindrome after replacement | C # program to get lexicographically smallest palindrome string ; Utility method to check str is possible palindrome after ignoring ; If both left and right character are not dot and they are not equal also , then it is not possible to make this string a palindrome ; Returns lexicographically smallest palindrome string , if possible ; loop through character of string ; if one of character is dot , replace dot with other character ; if both character are dot , then replace them with smallest character ' a ' ; return the result ; Driver code
using System ; public class GFG { static bool isPossiblePalindrome ( char [ ] str ) { int n = str . Length ; for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( str [ i ] != ' . ' && str [ n - i - 1 ] != ' . ' && str [ i ] != str [ n - i - 1 ] ) return false ; } return true ; } static void smallestPalindrome ( char [ ] str ) { if ( ! isPossiblePalindrome ( str ) ) Console . WriteLine ( " Not ▁ Possible " ) ; int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' . ' ) { if ( str [ n - i - 1 ] != ' . ' ) str [ i ] = str [ n - i - 1 ] ; else str [ i ] = str [ n - i - 1 ] = ' a ' ; } } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( str [ i ] + " " ) ; } public static void Main ( ) { String str = " ab . . e . c . a " ; char [ ] s = str . ToCharArray ( ) ; smallestPalindrome ( s ) ; } }
Number of flips to make binary string alternate | Set 1 | C # program to find minimum number of flip to make binary string alternate ; Utility method to flip a character ; Utility method to get minimum flips when alternate string starts with expected char ; if current character is not expected , increase flip count ; flip expected character each time ; method return minimum flip to make binary string alternate ; return minimum of following two 1 ) flips when alternate string starts with 0 2 ) flips when alternate string starts with 1 ; Driver Code
using System ; class GFG { public static char flip ( char ch ) { return ( ch == '0' ) ? '1' : '0' ; } public static int getFlipWithStartingCharcter ( String str , char expected ) { int flipCount = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] != expected ) flipCount ++ ; expected = flip ( expected ) ; } return flipCount ; } public static int minFlipToMakeStringAlternate ( string str ) { return Math . Min ( getFlipWithStartingCharcter ( str , '0' ) , getFlipWithStartingCharcter ( str , '1' ) ) ; } public static void Main ( ) { string str = "0001010111" ; Console . Write ( minFlipToMakeStringAlternate ( str ) ) ; } }
Remainder with 7 for large numbers | C # program to find the remainder of a large number when divided by 7. ; Function which return Remainder after dividingthe number by 7 ; This series is used to find remainder with 7 ; Index of next element in series ; Initialize result ; Traverse num from end ; Find current digit of nun ; Add next term to result ; Move to next term in series ; Make sure that result never goes beyond 7. ; Make sure that remainder is positive ; Driver code
using System ; class GFG { static int remainderWith7 ( String num ) { int [ ] series = { 1 , 3 , 2 , - 1 , - 3 , - 2 } ; int series_index = 0 ; int result = 0 ; for ( int i = num . Length - 1 ; i >= 0 ; i -- ) { int digit = num [ i ] - '0' ; result += digit * series [ series_index ] ; series_index = ( series_index + 1 ) % 6 ; result %= 7 ; } if ( result < 0 ) result = ( result + 7 ) % 7 ; return result ; } public static void Main ( ) { String str = "12345" ; Console . Write ( " Remainder ▁ with ▁ 7 ▁ is ▁ " + remainderWith7 ( str ) ) ; } }
Check if a string can become empty by recursively deleting a given sub | C # program to check if a string can be converted to an empty string by deleting given sub - string from any position , any number of times . ; Returns true if str can be made empty by recursively removing sub_str . ; idx : to store starting index of sub - string found in the original string ; Erasing the found sub - string from the original string ; Driver code
using System ; class GFG { static Boolean canBecomeEmpty ( String str , String sub_str ) { while ( str . Length > 0 ) { int idx = str . IndexOf ( sub_str ) ; if ( idx == - 1 ) { break ; } str = str . Replace ( sub_str , " " ) ; } return ( str . Length == 0 ) ; } public static void Main ( String [ ] args ) { String str = " GEEGEEKSKS " , sub_str = " GEEKS " ; if ( canBecomeEmpty ( str , sub_str ) ) { Console . Write ( " STRNEWLINE Yes " ) ; } else { Console . Write ( " STRNEWLINE No " ) ; } } }
Perfect reversible string | C # program to check if a string is perfect reversible or nor ; This function basically checks if string is palindrome or not ; iterate from left and right ; Driver Code
using System ; class GFG { public static bool isReversible ( string str ) { int i = 0 , j = str . Length - 1 ; while ( i < j ) { if ( str [ i ] != str [ j ] ) { return false ; } i ++ ; j -- ; } return true ; } public static void Main ( string [ ] args ) { string str = " aba " ; if ( isReversible ( str ) ) { Console . Write ( " YES " ) ; } else { Console . Write ( " NO " ) ; } } }
Check if string follows order of characters defined by a pattern or not | Set 3 | C # program to find if a string follows order defined by a given pattern . ; Returns true if characters of str follow order defined by a given ptr . ; Initialize all orders as - 1 ; Assign an order to pattern characters according to their appearance in pattern ; give the pattern characters order ; increment the order ; Now one by check if string characters follow above order ; If order of this character is less than order of previous , return false . ; Update last_order for next iteration ; return that str followed pat ; Driver code
using System ; class GFG { static int CHAR_SIZE = 256 ; static bool checkPattern ( String str , String pat ) { int [ ] label = new int [ CHAR_SIZE ] ; for ( int i = 0 ; i < CHAR_SIZE ; i ++ ) label [ i ] = - 1 ; int order = 1 ; for ( int i = 0 ; i < pat . Length ; i ++ ) { label [ pat [ i ] ] = order ; order ++ ; } int last_order = - 1 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( label [ str [ i ] ] != - 1 ) { if ( label [ str [ i ] ] < last_order ) return false ; last_order = label [ str [ i ] ] ; } } return true ; } public static void Main ( String [ ] args ) { String str = " engineers ▁ rock " ; String pattern = " gsr " ; Console . WriteLine ( checkPattern ( str , pattern ) ) ; } }
Check if string follows order of characters defined by a pattern or not | Set 2 | C # program to check if characters of a string follow pattern defined by given pattern . ; Insert all characters of pattern in a hash set , ; Build modified string ( string with characters only from pattern are taken ) ; Remove more than one consecutive occurrences of pattern characters from modified string . ; After above modifications , the length of modified string must be same as pattern length ; And pattern characters must also be same as modified string characters ; Driver program
using System ; using System . Collections . Generic ; using System . Text ; class GFG { public static bool followsPattern ( String str , String pattern ) { HashSet < char > patternSet = new HashSet < char > ( ) ; for ( int i = 0 ; i < pattern . Length ; i ++ ) patternSet . Add ( pattern [ i ] ) ; StringBuilder modifiedString = new StringBuilder ( str ) ; for ( int i = str . Length - 1 ; i >= 0 ; i -- ) if ( ! patternSet . Contains ( modifiedString [ i ] ) ) modifiedString . Remove ( i , 1 ) ; for ( int i = modifiedString . Length - 1 ; i > 0 ; i -- ) if ( modifiedString [ i ] == modifiedString [ i - 1 ] ) modifiedString . Remove ( i , 1 ) ; if ( pattern . Length != modifiedString . Length ) return false ; for ( int i = 0 ; i < pattern . Length ; i ++ ) if ( pattern [ i ] != modifiedString [ i ] ) return false ; return true ; } public static void Main ( String [ ] args ) { String str = " engineers ▁ rock " ; String pattern = " er " ; Console . WriteLine ( " Expected : ▁ true , ▁ Actual : ▁ " + followsPattern ( str , pattern ) ) ; str = " engineers ▁ rock " ; pattern = " egr " ; Console . WriteLine ( " Expected : ▁ false , ▁ Actual : ▁ " + followsPattern ( str , pattern ) ) ; str = " engineers ▁ rock " ; pattern = " gsr " ; Console . WriteLine ( " Expected : ▁ false , ▁ Actual : ▁ " + followsPattern ( str , pattern ) ) ; str = " engineers ▁ rock " ; pattern = " eger " ; Console . WriteLine ( " Expected : ▁ true , ▁ Actual : ▁ " + followsPattern ( str , pattern ) ) ; } }
Find k 'th character of decrypted string | Set 1 | C # program to find K 'th character in decrypted string ; Function to find K 'th  character in Encoded String ; expand string variable is used to store final string after decompressing string str ; String temp = " " ; Current substring int freq = 0 ; Count of current substring ; read characters until you find a number or end of string ; push character in temp ; read number for how many times string temp will be repeated in decompressed string ; generating frequency of temp ; now append string temp into expand equal to its frequency ; this condition is to handle the case when string str is ended with alphabets not with numeric value ; Driver Code
using System ; class GFG { static char encodedChar ( string str , int k ) { String expand = " " ; for ( int i = 0 ; i < str . Length ; ) { while ( i < str . Length && str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { temp += str [ i ] ; i ++ ; } while ( i < str . Length && str [ i ] >= '1' && str [ i ] <= '9' ) { freq = freq * 10 + str [ i ] - '0' ; i ++ ; } for ( int j = 1 ; j <= freq ; j ++ ) expand += temp ; } if ( freq == 0 ) expand += temp ; return expand [ k - 1 ] ; } public static void Main ( ) { string str = " ab4c12ed3" ; int k = 21 ; Console . Write ( encodedChar ( str , k ) ) ; } }
Converting Decimal Number lying between 1 to 3999 to Roman Numerals | C # Program for above approach ; Function to calculate roman equivalent ; storing roman values of digits from 0 - 9 when placed at different places ; Converting to roman ; Driver program to test above function
using System ; class GFG { static String intToRoman ( int num ) { String [ ] m = { " " , " M " , " MM " , " MMM " } ; String [ ] c = { " " , " C " , " CC " , " CCC " , " CD " , " D " , " DC " , " DCC " , " DCCC " , " CM " } ; String [ ] x = { " " , " X " , " XX " , " XXX " , " XL " , " L " , " LX " , " LXX " , " LXXX " , " XC " } ; String [ ] i = { " " , " I " , " II " , " III " , " IV " , " V " , " VI " , " VII " , " VIII " , " IX " } ; String thousands = m [ num / 1000 ] ; String hundereds = c [ ( num % 1000 ) / 100 ] ; String tens = x [ ( num % 100 ) / 10 ] ; String ones = i [ num % 10 ] ; String ans = thousands + hundereds + tens + ones ; return ans ; } public static void Main ( ) { int number = 3549 ; Console . WriteLine ( intToRoman ( number ) ) ; } }
Longest Common Prefix using Binary Search | C # Program to find the longest common prefix using System ; ; A Function to find the string having the minimum length and returns that length ; A Function that returns the longest common prefix from the array of strings ; We will do an in - place binary search on the first string of the array in the range 0 to index ; Same as ( low + high ) / 2 , but avoids overflow for large low and high ; If all the strings in the input array contains this prefix then append this substring to our answer ; And then go for the right part ; else Go for the left part ; Driver program to test above function
using System ; public class GFG { static int findMinLength ( string [ ] arr , int n ) { int min = int . MaxValue ; for ( int i = 0 ; i <= ( n - 1 ) ; i ++ ) { if ( arr [ i ] . Length < min ) { min = arr [ i ] . Length ; } } return min ; } static bool allContainsPrefix ( string [ ] arr , int n , string str , int start , int end ) { for ( int i = 0 ; i <= ( n - 1 ) ; i ++ ) { string arr_i = arr [ i ] ; for ( int j = start ; j <= end ; j ++ ) if ( arr_i [ j ] != str [ j ] ) return false ; } return true ; } static string commonPrefix ( string [ ] arr , int n ) { int index = findMinLength ( arr , n ) ; int low = 0 , high = index ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( allContainsPrefix ( arr , n , arr [ 0 ] , low , mid ) ) { prefix = prefix + arr [ 0 ] . Substring ( low , mid + 1 ) ; low = mid + 1 ; } { high = mid - 1 ; } } return prefix ; } public static void Main ( ) { string [ ] arr = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = arr . Length ; string ans = commonPrefix ( arr , n ) ; if ( ans . Length > 0 ) Console . WriteLine ( " The ▁ longest ▁ common " + " ▁ prefix ▁ is ▁ - ▁ " + ans ) ; else Console . WriteLine ( " There ▁ is ▁ no ▁ common " + " ▁ prefix " ) ; } }
Lower case to upper case | C # program to convert a string to uppercase ; Converts a string to uppercase ; Driver code
using System ; class GFG { static String to_upper ( char [ ] str ) { for ( int i = 0 ; i < str . Length ; i ++ ) if ( ' a ' <= str [ i ] && str [ i ] <= ' z ' ) str [ i ] = ( char ) ( ( int ) str [ i ] & ( ~ ( 1 << 5 ) ) ) ; return String . Join ( " " , str ) ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; Console . WriteLine ( to_upper ( str . ToCharArray ( ) ) ) ; } }
Longest Common Prefix using Divide and Conquer Algorithm | C # Program to find the longest common prefix ; A Utility Function to find the common prefix between strings - str1 and str2 ; A Divide and Conquer based function to find the longest common prefix . This is similar to the merge sort technique ; Same as ( low + high ) / 2 , but avoids overflow for large low and high ; Driver Code
using System ; class GFG { static string commonPrefixUtil ( string str1 , string str2 ) { string result = " " ; int n1 = str1 . Length , n2 = str2 . Length ; for ( int i = 0 , j = 0 ; i <= n1 - 1 && j <= n2 - 1 ; i ++ , j ++ ) { if ( str1 [ i ] != str2 [ j ] ) break ; result += str1 [ i ] ; } return ( result ) ; } static string commonPrefix ( string [ ] arr , int low , int high ) { if ( low == high ) return ( arr [ low ] ) ; if ( high > low ) { int mid = low + ( high - low ) / 2 ; string str1 = commonPrefix ( arr , low , mid ) ; string str2 = commonPrefix ( arr , mid + 1 , high ) ; return ( commonPrefixUtil ( str1 , str2 ) ) ; } return null ; } public static void Main ( ) { String [ ] arr = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = arr . Length ; String ans = commonPrefix ( arr , 0 , n - 1 ) ; if ( ans . Length != 0 ) { Console . Write ( " The ▁ longest ▁ common ▁ " + " prefix ▁ is ▁ " + ans ) ; } else { Console . Write ( " There ▁ is ▁ no ▁ common ▁ prefix " ) ; } } }