codeparrot/xlcost-text-to-code huggingface dataset:
Longest palindromic String formed using concatenation of given strings in any order | C # implementation to find the longest palindromic String formed using concatenation of given Strings in any order ; Function to find the longest palindromic from given array of Strings ; Loop to find the pair of Strings which are reverse of each other ; Loop to find if any palindromic String is still left in the array ; Update the answer with all Strings of pair1 ; Update the answer with palindromic String s1 ; Update the answer with all Strings of pair2 ; Driver Code
using System ; class GFG { static void longestPalindrome ( String [ ] a , int n ) { String [ ] pair1 = new String [ n ] ; String [ ] pair2 = new String [ n ] ; int r = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String s = a [ i ] ; s = reverse ( s ) ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( a [ i ] != " " && a [ j ] != " " ) { if ( s . Equals ( a [ j ] ) ) { pair1 [ r ] = a [ i ] ; pair2 [ r ++ ] = a [ j ] ; a [ i ] = " " ; a [ j ] = " " ; break ; } } } } String s1 = " " ; for ( int i = 0 ; i < n ; i ++ ) { String s = a [ i ] ; a [ i ] = reverse ( a [ i ] ) ; if ( a [ i ] != " " ) { if ( a [ i ] . Equals ( s ) ) { s1 = a [ i ] ; break ; } } } String ans = " " ; for ( int i = 0 ; i < r ; i ++ ) { ans = ans + pair1 [ i ] ; } if ( s1 != " " ) { ans = ans + s1 ; } for ( int j = r - 1 ; j >= 0 ; j -- ) { ans = ans + pair2 [ j ] ; } Console . Write ( ans + " STRNEWLINE " ) ; } 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 ) ; } public static void Main ( String [ ] args ) { String [ ] a1 = { " aba " , " aba " } ; int n1 = a1 . Length ; longestPalindrome ( a1 , n1 ) ; String [ ] a2 = { " abc " , " dba " , " kop " , " abd " , " cba " } ; int n2 = a2 . Length ; longestPalindrome ( a2 , n2 ) ; } }
Program to print the given digit in words | C # implementation of the above approach ; Function to return the word of the corresponding digit ; Switch block to check for each digit c ; For digit 0 ; For digit 1 ; For digit 2 ; For digit 3 ; For digit 4 ; For digit 5 ; For digit 6 ; For digit 7 ; For digit 8 ; For digit 9 ; Function to iterate through every digit in the given number ; Finding each digit of the number ; Print the digit in words ; Driver code
using System ; class GFG { static void printValue ( char digit ) { switch ( digit ) { case '0' : Console . Write ( " Zero ▁ " ) ; break ; case '1' : Console . Write ( " One ▁ " ) ; break ; case '2' : Console . Write ( " Two ▁ " ) ; break ; case '3' : Console . Write ( " Three ▁ " ) ; break ; case '4' : Console . Write ( " Four ▁ " ) ; break ; case '5' : Console . Write ( " Five ▁ " ) ; break ; case '6' : Console . Write ( " Six ▁ " ) ; break ; case '7' : Console . Write ( " Seven ▁ " ) ; break ; case '8' : Console . Write ( " Eight ▁ " ) ; break ; case '9' : Console . Write ( " Nine ▁ " ) ; break ; } } static void printWord ( string N ) { int i , length = N . Length ; for ( i = 0 ; i < length ; i ++ ) { printValue ( N [ i ] ) ; } } public static void Main ( ) { string N = "123" ; printWord ( N ) ; } }
Print all possible combinations of words from Dictionary using Trie | C # implementation of the approach ; Trie node ; isEndOfWord is true if node represents the end of the word ; Returns new trie node ; If not present , inserts key into trie If the key is prefix of trie node , marks the node as leaf node ; Mark node as leaf ; Returns true if the key is present in the trie ; Result stores the current prefix with spaces between words ; Process all prefixes one by one ; Extract subString from 0 to i in prefix ; If trie conatins this prefix then check for the remaining String . Otherwise ignore this prefix ; If no more elements are there then print ; Add this element to the previous prefix ; If ( result == word ) then return If you don 't want to print last word ; Driver code
using System ; class GFG { static int ALPHABET_SIZE = 26 ; class TrieNode { public TrieNode [ ] children = new TrieNode [ ALPHABET_SIZE ] ; public bool isEndOfWord ; public TrieNode ( ) { } } ; static TrieNode getNode ( ) { TrieNode pNode = new TrieNode ( ) ; pNode . isEndOfWord = false ; for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) pNode . children [ i ] = null ; return pNode ; } static void insert ( TrieNode root , String key ) { TrieNode pCrawl = root ; for ( int i = 0 ; i < key . Length ; i ++ ) { int index = key [ i ] - ' a ' ; if ( pCrawl . children [ index ] == null ) pCrawl . children [ index ] = getNode ( ) ; pCrawl = pCrawl . children [ index ] ; } pCrawl . isEndOfWord = true ; } static bool search ( TrieNode root , String key ) { TrieNode pCrawl = root ; for ( int i = 0 ; i < key . Length ; i ++ ) { int index = key [ i ] - ' a ' ; if ( pCrawl . children [ index ] == null ) return false ; pCrawl = pCrawl . children [ index ] ; } return ( pCrawl != null && pCrawl . isEndOfWord ) ; } static void wordBreakAll ( TrieNode root , String word , int n , String result ) { for ( int i = 1 ; i <= n ; i ++ ) { String prefix = word . Substring ( 0 , i ) ; if ( search ( root , prefix ) ) { if ( i == n ) { result += prefix ; Console . Write ( " TABSYMBOL " + result + " STRNEWLINE " ) ; return ; } wordBreakAll ( root , word . Substring ( i , n - i ) , n - i , result + prefix + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { new TrieNode ( ) ; TrieNode root = getNode ( ) ; String [ ] dictionary = { " sam " , " sung " , " samsung " } ; int n = dictionary . Length ; for ( int i = 0 ; i < n ; i ++ ) { insert ( root , dictionary [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( dictionary [ i ] + " : ▁ STRNEWLINE " ) ; wordBreakAll ( root , dictionary [ i ] , dictionary [ i ] . Length , " " ) ; } } }
Jaro and Jaro | C # implementation of above approach ; Function to calculate the Jaro Similarity of two Strings ; If the Strings are equal ; Length of two Strings ; Maximum distance upto which matching is allowed ; Count of matches ; Hash for matches ; Traverse through the first String ; Check if there is any matches ; If there is a match ; If there is no match ; Number of transpositions ; Count number of occurrences where two characters match but there is a third matched character in between the indices ; Find the next matched character in second String ; Return the Jaro Similarity ; Driver code ; Print jaro Similarity of two Strings
using System ; class GFG { static double jaro_distance ( string s1 , string s2 ) { if ( s1 == s2 ) return 1.0 ; int len1 = s1 . Length ; int len2 = s2 . Length ; int max_dist = ( int ) ( Math . Floor ( ( double ) ( ( Math . Max ( len1 , len2 ) / 2 ) - 1 ) ) ) ; int match = 0 ; int [ ] hash_s1 = new int [ s1 . Length ] ; int [ ] hash_s2 = new int [ s2 . Length ] ; for ( int i = 0 ; i < len1 ; i ++ ) { for ( int j = Math . Max ( 0 , i - max_dist ) ; j < Math . Min ( len2 , i + max_dist + 1 ) ; j ++ ) if ( s1 [ i ] == s2 [ j ] && hash_s2 [ j ] == 0 ) { hash_s1 [ i ] = 1 ; hash_s2 [ j ] = 1 ; match ++ ; break ; } } if ( match == 0 ) return 0.0 ; double t = 0 ; int point = 0 ; for ( int i = 0 ; i < len1 ; i ++ ) if ( hash_s1 [ i ] == 1 ) { while ( hash_s2 [ point ] == 0 ) point ++ ; if ( s1 [ i ] != s2 [ point ++ ] ) t ++ ; } t /= 2 ; return ( ( ( double ) match ) / ( ( double ) len1 ) + ( ( double ) match ) / ( ( double ) len2 ) + ( ( double ) match - t ) / ( ( double ) match ) ) / 3.0 ; } public static void Main ( ) { string s1 = " CRATE " , s2 = " TRACE " ; Console . WriteLine ( jaro_distance ( s1 , s2 ) ) ; } }
Print characters and their frequencies in order of occurrence using Binary Tree | C # implementation of the above approach ; Node in the tree where data holds the character of the String and cnt holds the frequency ; Function to add a new node to the Binary Tree ; Create a new node and populate its data part , set cnt as 1 and left and right children as null ; Function to add a node to the Binary Tree in level order ; Use the queue data structure for level order insertion and push the root of tree to Queue ; If the character to be inserted is present , update the cnt ; If the left child is empty add a new node as the left child ; If the character is present as a left child , update the cnt and exit the loop ; Add the left child to the queue for further processing ; If the right child is empty , add a new node to the right ; If the character is present as a right child , update the cnt and exit the loop ; Add the right child to the queue for further processing ; Function to print the level order traversal of the Binary Tree ; Add the root to the queue ; If the cnt of the character is more then one , display cnt ; If the cnt of character is one , display character only ; Add the left child to the queue for further processing ; Add the right child to the queue for further processing ; Driver code ; Add individual characters to the String one by one in level order ; Print the level order of the constructed binary tree
using System ; using System . Collections . Generic ; class GFG { public class node { public char data ; public int cnt ; public node left , right ; } ; static node add ( char data ) { node newnode = new node ( ) ; newnode . data = data ; newnode . cnt = 1 ; newnode . left = newnode . right = null ; return newnode ; } static node addinlvlorder ( node root , char data ) { if ( root == null ) { return add ( data ) ; } List < node > Q = new List < node > ( ) ; Q . Add ( root ) ; while ( Q . Count != 0 ) { node temp = Q [ 0 ] ; Q . RemoveAt ( 0 ) ; if ( temp . data == data ) { temp . cnt ++ ; break ; } if ( temp . left == null ) { temp . left = add ( data ) ; break ; } else { if ( temp . left . data == data ) { temp . left . cnt ++ ; break ; } Q . Add ( temp . left ) ; } if ( temp . right == null ) { temp . right = add ( data ) ; break ; } else { if ( temp . right . data == data ) { temp . right . cnt ++ ; break ; } Q . Add ( temp . right ) ; } } return root ; } static void printlvlorder ( node root ) { List < node > Q = new List < node > ( ) ; Q . Add ( root ) ; while ( Q . Count != 0 ) { node temp = Q [ 0 ] ; if ( temp . cnt > 1 ) { Console . Write ( ( temp . data + " " + temp . cnt ) ) ; } else { Console . Write ( ( char ) temp . data ) ; } Q . RemoveAt ( 0 ) ; if ( temp . left != null ) { Q . Add ( temp . left ) ; } if ( temp . right != null ) { Q . Add ( temp . right ) ; } } } public static void Main ( String [ ] args ) { String s = " geeksforgeeks " ; node root = null ; for ( int i = 0 ; i < s . Length ; i ++ ) { root = addinlvlorder ( root , s [ i ] ) ; } printlvlorder ( root ) ; } }
Find the resultant String after replacing X with Y and removing Z | C # program to find the resultant String after replacing X with Y and removing Z ; Function to replace and remove ; Two pointer start and end points to beginning and end position in the string ; If start is having Z find X pos in end and replace Z with another character ; Find location for having different character instead of Z ; If found swap character at start and end ; Else increment start Also checkin for X at start position ; Driver code
using System ; class GFG { static String replaceRemove ( char [ ] s , char X , char Y , char Z ) { int start = 0 , end = s . Length - 1 ; while ( start <= end ) { if ( s [ start ] == Z ) { while ( end >= 0 && s [ end ] == Z ) { end -- ; } char temp ; if ( end > start ) { temp = s [ start ] ; s [ start ] = s [ end ] ; s [ end ] = temp ; if ( s [ start ] == X ) s [ start ] = Y ; start ++ ; } } else { if ( s [ start ] == X ) s [ start ] = Y ; start ++ ; } } String new_s = new String ( s ) ; while ( new_s . Length > 0 && new_s [ new_s . Length - 1 ] == Z ) { new_s = new_s . Substring ( 0 , new_s . Length - 1 ) ; } return new_s ; } public static void Main ( String [ ] args ) { String str = " batman " ; char X = ' a ' , Y = ' d ' , Z = ' b ' ; str = replaceRemove ( str . ToCharArray ( ) , X , Y , Z ) ; if ( str . Length == 0 ) { Console . WriteLine ( - 1 ) ; } else { Console . WriteLine ( str ) ; } } }
Check if all bits can be made same by flipping two consecutive bits | C # program for the above approach ; Function to check if Binary string can be made equal ; Counting occurence of zero and one in binary string ; From above observation ; Driver code
using System ; class GFG { static string canMake ( string s ) { int o = 0 , z = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] - '0' == 1 ) o ++ ; else z ++ ; } if ( o % 2 == 1 && z % 2 == 1 ) return " NO " ; else return " YES " ; } public static void Main ( ) { string s = "01011" ; Console . WriteLine ( canMake ( s ) ) ; } }
Minimum swaps required to make a binary string divisible by 2 ^ k | C # implementation of the approach ; Function to return the minimum swaps required ; To store the final answer ; To store the count of one and zero ; Loop from end of the string ; If s [ i ] = 1 ; If s [ i ] = 0 ; If c_zero = k ; If the result can 't  be achieved ; Return the final answer ; Driver code
using System ; class GFG { static int findMinSwaps ( string s , int k ) { int ans = 0 ; int c_one = 0 , c_zero = 0 ; for ( int i = s . Length - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == '1' ) c_one ++ ; if ( s [ i ] == '0' ) { c_zero ++ ; ans += c_one ; } if ( c_zero == k ) break ; } if ( c_zero < k ) return - 1 ; return ans ; } public static void Main ( ) { string s = "100111" ; int k = 2 ; Console . WriteLine ( findMinSwaps ( s , k ) ) ; } }
Remove vowels from a string stored in a Binary Tree | C # program for the above approach ; Structure Representing the Node in the Binary tree ; Function to perform a level order insertion of a new Node in the Binary tree ; If the root is empty , make it point to the new Node ; In case there are elements in the Binary tree , perform a level order traversal using a Queue ; If the left child does not exist , insert the new Node as the left child ; In case the right child does not exist , insert the new Node as the right child ; Function to print the level order traversal of the Binary tree ; Function to check if the character is a vowel or not . ; Function to remove the vowels in the new Binary tree ; Declaring the root of the new tree ; If the given character is not a vowel , add it to the new Binary tree ; Driver code
using System ; using System . Collections . Generic ; class GFG { class Node { public char data ; public Node left , right ; public Node ( char _val ) { data = _val ; left = right = null ; } } ; static Node addinBT ( Node root , char data ) { if ( root == null ) { root = new Node ( data ) ; } else { List < Node > Q = new List < Node > ( ) ; Q . Add ( root ) ; while ( Q . Count != 0 ) { Node temp = Q [ 0 ] ; Q . RemoveAt ( 0 ) ; if ( temp . left == null ) { temp . left = new Node ( data ) ; break ; } else Q . Add ( temp . left ) ; if ( temp . right == null ) { temp . right = new Node ( data ) ; break ; } else Q . Add ( temp . right ) ; } } return root ; } static void print ( Node root ) { List < Node > Q = new List < Node > ( ) ; Q . Add ( root ) ; while ( Q . Count > 0 ) { Node temp = Q [ 0 ] ; Q . RemoveAt ( 0 ) ; Console . Write ( temp . data ) ; if ( temp . left != null ) Q . Add ( temp . left ) ; if ( temp . right != null ) Q . Add ( temp . right ) ; } } static bool checkvowel ( char ch ) { ch = char . ToLower ( ch ) ; if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) { return true ; } else { return false ; } } static Node removevowels ( Node root ) { List < Node > Q = new List < Node > ( ) ; Q . Add ( root ) ; Node root1 = null ; while ( Q . Count != 0 ) { Node temp = Q [ 0 ] ; Q . RemoveAt ( 0 ) ; if ( ! checkvowel ( temp . data ) ) { root1 = addinBT ( root1 , temp . data ) ; } if ( temp . left != null ) { Q . Add ( temp . left ) ; } if ( temp . right != null ) { Q . Add ( temp . right ) ; } } return root1 ; } public static void Main ( String [ ] args ) { String s = " geeks " ; Node root = null ; for ( int i = 0 ; i < s . Length ; i ++ ) { root = addinBT ( root , s [ i ] ) ; } root = removevowels ( root ) ; print ( root ) ; } }
Number of sub | C # implementation of the approach ; Function to return the count of the required substrings ; To store the final answer ; Loop to find the answer ; Condition to update the answer ; Driver code
using System ; class GFG { static int countSubStr ( string str , int len ) { int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) ans += ( i + 1 ) ; } return ans ; } public static void Main ( ) { string str = "10010" ; int len = str . Length ; Console . WriteLine ( countSubStr ( str , len ) ) ; } }
Smallest non | C # implementation of the approach ; Function to return the length of the smallest substring divisible by 2 ^ k ; To store the final answer ; Left pointer ; Right pointer ; Count of the number of zeros and ones in the current substring ; Loop for two pointers ; Condition satisfied ; Updated the answer ; Update the pointer and count ; Update the pointer and count ; Driver code
using System ; class GFG { static int INT_MAX = int . MaxValue ; static int findLength ( string s , int k ) { int ans = INT_MAX ; int l = 0 ; int r = 0 ; int cnt_zero = 0 , cnt_one = 0 ; while ( l < s . Length && r <= s . Length ) { if ( cnt_zero >= k && cnt_one >= 1 ) { ans = Math . Min ( ans , r - l ) ; l ++ ; if ( s [ l - 1 ] == '0' ) cnt_zero -- ; else cnt_one -- ; } else { if ( r == s . Length ) break ; if ( s [ r ] == '0' ) cnt_zero ++ ; else cnt_one ++ ; r ++ ; } } if ( ans == INT_MAX ) return - 1 ; return ans ; } public static void Main ( ) { string s = "100" ; int k = 2 ; Console . WriteLine ( findLength ( s , k ) ) ; } }
Largest sub | C # implementation of the approach ; Function to return the largest substring divisible by 2 ; While the last character of the string is '1' , pop it ; If the original string had no '0' ; Driver code
using System ; class GFG { static string largestSubStr ( string s ) { while ( s . Length != 0 && s [ s . Length - 1 ] == '1' ) s = s . Substring ( 0 , s . Length - 1 ) ; if ( s . Length == 0 ) return " - 1" ; else return s ; } public static void Main ( ) { string s = "11001" ; Console . WriteLine ( largestSubStr ( s ) ) ; } }
Find whether X exists in Y after jumbling X | C # implementation of the approach ; Function that returns true if both the arrays have equal values ; Test the equality ; Function that returns true if any permutation of X exists as a subString in Y ; Base case ; To store cumulative frequency ; Finding the frequency of characters in X ; Finding the frequency of characters in Y upto the length of X ; Equality check ; Two pointer approach to generate the entire cumulative frequency ; Remove the first character of the previous window ; Add the last character of the current window ; Equality check ; Driver code
using System ; class GFG { static int MAX = 26 ; static bool areEqual ( int [ ] a , int [ ] b ) { for ( int i = 0 ; i < MAX ; i ++ ) if ( a [ i ] != b [ i ] ) return false ; return true ; } static bool xExistsInY ( String x , String y ) { if ( x . Length > y . Length ) return false ; int [ ] cnt_x = new int [ MAX ] ; int [ ] cnt = new int [ MAX ] ; for ( int i = 0 ; i < x . Length ; i ++ ) cnt_x [ x [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < x . Length ; i ++ ) cnt [ y [ i ] - ' a ' ] ++ ; if ( areEqual ( cnt_x , cnt ) ) return true ; for ( int i = 1 ; i < y . Length - x . Length + 1 ; i ++ ) { cnt [ y [ i - 1 ] - ' a ' ] -- ; cnt [ y [ i + x . Length - 1 ] - ' a ' ] ++ ; if ( areEqual ( cnt , cnt_x ) ) return true ; } return false ; } public static void Main ( String [ ] args ) { String x = " skege " ; String y = " geeksforgeeks " ; if ( xExistsInY ( x , y ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Reverse substrings between each pair of parenthesis | C # implementation of the approach ; Function to return the modified string ; Push the index of the current opening bracket ; Reverse the substring starting after the last encountered opening bracket till the current character ; To store the modified string ; Driver code
using System ; using System . Collections . Generic ; using System . Text ; class GFG { static void reverse ( char [ ] A , int l , int h ) { if ( l < h ) { char ch = A [ l ] ; A [ l ] = A [ h ] ; A [ h ] = ch ; reverse ( A , l + 1 , h - 1 ) ; } } static string reverseParentheses ( string str , int len ) { Stack < int > st = new Stack < int > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' ( ' ) { st . Push ( i ) ; } else if ( str [ i ] == ' ) ' ) { char [ ] A = str . ToCharArray ( ) ; reverse ( A , st . Peek ( ) + 1 , i ) ; str = new string ( A ) ; st . Pop ( ) ; } } string res = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] != ' ) ' && str [ i ] != ' ( ' ) { res += str [ i ] ; } } return res ; } static public void Main ( ) { string str = " ( skeeg ( for ) skeeg ) " ; int len = str . Length ; Console . WriteLine ( reverseParentheses ( str , len ) ) ; } }
Count of times second string can be formed from the characters of first string | C # implementation of the approach ; Function to update the [ ] freq array to store the frequencies of all the characters of str ; Update the frequency of the characters ; Function to return the maximum count of times patt can be formed using the characters of str ; To store the frequencies of all the characters of str ; To store the frequencies of all the characters of patt ; To store the result ; For every character ; If the current character doesn 't appear in patt ; Update the result ; Driver code
using System ; class GFG { static int MAX = 26 ; static void updateFreq ( String str , int [ ] freq ) { int len = str . Length ; for ( int i = 0 ; i < len ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } } static int maxCount ( String str , String patt ) { int [ ] strFreq = new int [ MAX ] ; updateFreq ( str , strFreq ) ; int [ ] pattFreq = new int [ MAX ] ; updateFreq ( patt , pattFreq ) ; int ans = int . MaxValue ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( pattFreq [ i ] == 0 ) continue ; ans = Math . Min ( ans , strFreq [ i ] / pattFreq [ i ] ) ; } return ans ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; String patt = " geeks " ; Console . Write ( maxCount ( str , patt ) ) ; } }
Reduce the number to minimum multiple of 4 after removing the digits | C # implementation of the approach ; Function to return the minimum number that can be formed after removing the digits which is a multiple of 4 ; For every digit of the number ; Check if the current digit is divisible by 4 ; If any subsequence of two digits is divisible by 4 ; Driver code
using System ; class GFG { static int TEN = 10 ; static int minNum ( char [ ] str , int len ) { int res = int . MaxValue ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '4' str [ i ] == '8' ) { res = Math . Min ( res , str [ i ] - '0' ) ; } } for ( int i = 0 ; i < len - 1 ; i ++ ) { for ( int j = i + 1 ; j < len ; j ++ ) { int num = ( str [ i ] - '0' ) * TEN + ( str [ j ] - '0' ) ; if ( num % 4 == 0 ) { res = Math . Min ( res , num ) ; } } } return ( ( res == int . MaxValue ) ? - 1 : res ) ; } public static void Main ( String [ ] args ) { String str = "17" ; int len = str . Length ; Console . Write ( minNum ( str . ToCharArray ( ) , len ) ) ; } }