codeparrot/xlcost-text-to-code huggingface dataset:
Put spaces between words starting with capital letters | C # program to put spaces between words starting with capital letters . ; Function to amend the sentence ; Traverse the string ; Convert to lowercase if its an uppercase character ; Print space before it if its an uppercase character ; Print the character ; if lowercase character then just print ; Driver Code
using System ; public class GFG { public static void amendSentence ( string sstr ) { char [ ] str = sstr . ToCharArray ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { str [ i ] = ( char ) ( str [ i ] + 32 ) ; if ( i != 0 ) Console . Write ( " ▁ " ) ; Console . Write ( str [ i ] ) ; } else Console . Write ( str [ i ] ) ; } } public static void Main ( ) { string str = " BruceWayneIsBatman " ; amendSentence ( str ) ; } }
C ++ program to concatenate a string given number of times | C # program to concatenate given string n number of times ; Function which return string by concatenating it . ; Copying given string to temporary string . ; Concatenating strings ; Driver code
using System ; class GFG { static String repeat ( String s , int n ) { String s1 = s ; for ( int i = 1 ; i < n ; i ++ ) s += s1 ; return s ; } public static void Main ( ) { String s = " geeks " ; int n = 3 ; Console . Write ( repeat ( s , n ) ) ; } }
Number of distinct permutation a String can have | C # program to find number of distinct permutations of a string . ; Utility function to find factorial of n . ; Returns count of distinct permutations of str . ; finding frequency of all the lower case alphabet and storing them in array of integer ; finding factorial of number of appearances and multiplying them since they are repeating alphabets ; finding factorial of size of string and dividing it by factorial found after multiplying ; Driver code
using System ; public class GFG { static int MAX_CHAR = 26 ; static int factorial ( int n ) { int fact = 1 ; for ( int i = 2 ; i <= n ; i ++ ) fact = fact * i ; return fact ; } static int countDistinctPermutations ( String str ) { int length = str . Length ; int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < length ; i ++ ) if ( str [ i ] >= ' a ' ) freq [ str [ i ] - ' a ' ] ++ ; int fact = 1 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) fact = fact * factorial ( freq [ i ] ) ; return factorial ( length ) / fact ; } public static void Main ( String [ ] args ) { String str = " fvvfhvgv " ; Console . Write ( countDistinctPermutations ( str ) ) ; } }
Determine if a string has all Unique Characters | C # program to illustrate String with unique characters without using any data structure ; Assuming string can have characters a - z this has 32 bits set to 0 ; if that bit is already set in checker , return false ; otherwise update and continue by setting that bit in the checker ; no duplicates encountered , return true ; Driver Code
using System ; class GFG { public virtual bool uniqueCharacters ( string str ) { int checker = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { int bitAtIndex = str [ i ] - ' a ' ; if ( ( checker & ( 1 << bitAtIndex ) ) > 0 ) { return false ; } checker = checker | ( 1 << bitAtIndex ) ; } return true ; } public static void Main ( string [ ] args ) { GFG obj = new GFG ( ) ; string input = " geekforgeeks " ; if ( obj . uniqueCharacters ( input ) ) { Console . WriteLine ( " The ▁ String ▁ " + input + " ▁ has ▁ all ▁ unique ▁ characters " ) ; } else { Console . WriteLine ( " The ▁ String ▁ " + input + " ▁ has ▁ duplicate ▁ characters " ) ; } } }
Alternate vowel and consonant string | C # implementation of alternate vowel and consonant string ; ' ch ' is vowel or not ; create alternate vowel and consonant string str1 [ 0. . . l1 - 1 ] and str2 [ start ... l2 - 1 ] ; first adding character of vowel / consonant then adding character of consonant / vowel ; function to find the required alternate vowel and consonant string ; count vowels and update vowel string ; count consonants and update consonant string ; no such string can be formed ; remove first character of vowel string then create alternate string with cstr [ 0. . . nc - 1 ] and vstr [ 1. . . nv - 1 ] ; remove first character of consonant string then create alternate string with vstr [ 0. . . nv - 1 ] and cstr [ 1. . . nc - 1 ] ; if both vowel and consonant strings are of equal length start creating string with consonant ; start creating string with vowel ; Driver code
using System ; class GFG { static Boolean isVowel ( char ch ) { if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) return true ; return false ; } static String createAltStr ( String str1 , String str2 , int start , int l ) { String finalStr = " " ; for ( int i = 0 , j = start ; j < l ; i ++ , j ++ ) finalStr = ( finalStr + str1 [ i ] ) + str2 [ j ] ; return finalStr ; } static String findAltStr ( String str ) { int nv = 0 , nc = 0 ; String vstr = " " , cstr = " " ; int l = str . Length ; for ( int i = 0 ; i < l ; i ++ ) { char ch = str [ i ] ; if ( isVowel ( ch ) ) { nv ++ ; vstr = vstr + ch ; } else { nc ++ ; cstr = cstr + ch ; } } if ( Math . Abs ( nv - nc ) >= 2 ) return " no ▁ such ▁ string " ; if ( nv > nc ) return ( vstr [ 0 ] + createAltStr ( cstr , vstr , 1 , nv ) ) ; if ( nc > nv ) return ( cstr [ 0 ] + createAltStr ( vstr , cstr , 1 , nc ) ) ; if ( cstr [ 0 ] < vstr [ 0 ] ) return createAltStr ( cstr , vstr , 0 , nv ) ; return createAltStr ( vstr , cstr , 0 , nc ) ; } public static void Main ( String [ ] args ) { String str = " geeks " ; Console . WriteLine ( findAltStr ( str ) ) ; } }
Check whether K | C # program to check if k - th bit of a given number is set or not . ; Driver code
using System ; class GFG { public static void isKthBitSet ( int n , int k ) { if ( ( n & ( 1 << ( k - 1 ) ) ) > 0 ) Console . Write ( " SET " ) ; else Console . Write ( " NOT ▁ SET " ) ; } public static void Main ( ) { int n = 5 , k = 1 ; isKthBitSet ( n , k ) ; } }
Reverse string without using any temporary variable | Reversing a string using reverse ( ) ; Reverse str [ beign . . end ]
using System ; using System . Linq ; class GFG { public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; str = new string ( str . Reverse ( ) . ToArray ( ) ) ; Console . WriteLine ( str ) ; } }
Recursive function to check if a string is palindrome | A recursive C # program to check whether a given number is palindrome or not ; A recursive function that check a str ( s . . e ) is palindrome or not . ; If there is only one character ; If first and last character do not match ; If there are more than two characters , check if middle substring is also palindrome or not . ; An empty string is considered as palindrome ; Driver Code
using System ; class GFG { static bool isPalRec ( String str , int s , int e ) { if ( s == e ) return true ; if ( ( str [ s ] ) != ( str [ e ] ) ) return false ; if ( s < e + 1 ) return isPalRec ( str , s + 1 , e - 1 ) ; return true ; } static bool isPalindrome ( String str ) { int n = str . Length ; if ( n == 0 ) return true ; return isPalRec ( str , 0 , n - 1 ) ; } public static void Main ( ) { String str = " geeg " ; if ( isPalindrome ( str ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Count substrings with same first and last characters | Most efficient C # program to count all substrings with same first and last characters . ; assuming lower case only ; Calculating frequency of each character in the string . ; Computing result using counts ; Driver code
using System ; class GFG { static readonly int MAX_CHAR = 26 ; static int countSubstringWithEqualEnds ( String s ) { int result = 0 ; int n = s . Length ; int [ ] count = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) count [ s [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) result += ( count [ i ] * ( count [ i ] + 1 ) / 2 ) ; return result ; } public static void Main ( ) { String s = " abcab " ; Console . Write ( countSubstringWithEqualEnds ( s ) ) ; } }
Maximum consecutive repeating character in string | C # program to find the maximum consecutive repeating character in given string ; function to find out the maximum repeating character in given string ; Traverse string except last character ; If current character matches with next ; If doesn 't match, update result  (if required) and reset count ; Driver code
using System ; class GFG { static char maxRepeating ( string str ) { int n = str . Length ; int count = 0 ; char res = str [ 0 ] ; int cur_count = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < n - 1 && str [ i ] == str [ i + 1 ] ) cur_count ++ ; else { if ( cur_count > count ) { count = cur_count ; res = str [ i ] ; } cur_count = 1 ; } } return res ; } public static void Main ( ) { string str = " aaaabbaaccde " ; Console . Write ( maxRepeating ( str ) ) ; } }
Queries on subsequence of string | C # program to answer subsequence queries for a given string ; Precompute the position of each character from each position of String S ; Computing position of each character from each position of String S ; Print " Yes " if T is subsequence of S , else " No " ; Traversing the string T ; If next position is greater than length of S set flag to false . ; Setting position of next character ; Driver Code
using System ; public class Query_Subsequence { static int MAX = 10000 ; static int CHAR_SIZE = 26 ; static void precompute ( int [ , ] mat , string str , int len ) { for ( int i = 0 ; i < CHAR_SIZE ; ++ i ) mat [ len , i ] = len ; for ( int i = len - 1 ; i >= 0 ; -- i ) { for ( int j = 0 ; j < CHAR_SIZE ; ++ j ) mat [ i , j ] = mat [ i + 1 , j ] ; mat [ i , str [ i ] - ' a ' ] = i ; } } static bool query ( int [ , ] mat , string str , int len ) { int pos = 0 ; for ( int i = 0 ; i < str . Length ; ++ i ) { if ( mat [ pos , str [ i ] - ' a ' ] >= len ) return false ; else pos = mat [ pos , str [ i ] - ' a ' ] + 1 ; } return true ; } public static void Main ( ) { string S = " geeksforgeeks " ; int len = S . Length ; int [ , ] mat = new int [ MAX , CHAR_SIZE ] ; precompute ( mat , S , len ) ; string get = query ( mat , " gg " , len ) ? " Yes " : " No " ; Console . WriteLine ( get ) ; get = query ( mat , " gro " , len ) ? " Yes " : " No " ; Console . WriteLine ( get ) ; get = query ( mat , " gfg " , len ) ? " Yes " : " No " ; Console . WriteLine ( get ) ; get = query ( mat , " orf " , len ) ? " Yes " : " No " ; Console . WriteLine ( get ) ; } }
Queries for characters in a repeated string | C # Program to Queries for same characters in a repeated string ; Print whether index i and j have same element or not ; Finding relative position of index i , j . ; Checking is element are same at index i , j ; Driver Code
using System ; public class GFG { static void query ( string s , int i , int j ) { int n = s . Length ; i %= n ; j %= n ; if ( s [ i ] == s [ j ] ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static public void Main ( ) { string X = " geeksforgeeks " ; query ( X , 0 , 8 ) ; query ( X , 8 , 13 ) ; query ( X , 6 , 15 ) ; } }
Count of character pairs at same distance as in English alphabets | A Simple C # program to find pairs with distance equal to English alphabet distance ; Method to count pairs ; Increment count if characters are at same distance ; Driver method
using System ; class Test { static int countPairs ( string str ) { int result = 0 ; int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( Math . Abs ( str [ i ] - str [ j ] ) == Math . Abs ( i - j ) ) result ++ ; return result ; } public static void Main ( ) { string str = " geeksforgeeks " ; Console . WriteLine ( countPairs ( str ) ) ; } }
Longest common subsequence with permutations allowed | C # program to find LCS with permutations allowed ; Function to calculate longest String str1 -- > first String str2 -- > second String count1 [ ] -- > hash array to calculate frequency of characters in str1 count [ 2 ] -- > hash array to calculate frequency of characters in str2 result -- > resultant longest String whose permutations are sub - sequence of given two strings ; calculate frequency of characters ; Now traverse hash array ; append character ( ' a ' + i ) in resultant String ' result ' by min ( count1 [ i ] , count2i ] ) times ; Driver Code
using System ; class GFG { static void longestString ( String str1 , String str2 ) { int [ ] count1 = new int [ 26 ] ; int [ ] count2 = new int [ 26 ] ; for ( int i = 0 ; i < str1 . Length ; i ++ ) { count1 [ str1 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < str2 . Length ; i ++ ) { count2 [ str2 [ i ] - ' a ' ] ++ ; } String result = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 1 ; j <= Math . Min ( count1 [ i ] , count2 [ i ] ) ; j ++ ) { result += ( char ) ( ' a ' + i ) ; } } Console . Write ( result ) ; } public static void Main ( ) { String str1 = " geeks " , str2 = " cake " ; longestString ( str1 , str2 ) ; } }
Check if string follows order of characters defined by a pattern or not | Set 1 | C # program check if characters in the input string follows the same order as determined by characters present in the given pattern ; Function to check if characters in the input string follows the same order as determined by characters present in the given pattern ; len stores length of the given pattern ; if length of pattern is more than length of input string , return false ; ; x , y are two adjacent characters in pattern ; find index of last occurrence of character x in the input string ; find index of first occurrence of character y in the input string ; return false if x or y are not present in the input string OR last occurrence of x is after the first occurrence of y in the input string ; return true if string matches the pattern ; Driver code
using System ; class GFG { static Boolean checkPattern ( String str , String pattern ) { int len = pattern . Length ; if ( str . Length < len ) { return false ; } for ( int i = 0 ; i < len - 1 ; i ++ ) { char x = pattern [ i ] ; char y = pattern [ i + 1 ] ; int last = str . LastIndexOf ( x ) ; int first = str . IndexOf ( y ) ; if ( last == - 1 first == - 1 last > first ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String str = " engineers ▁ rock " ; String pattern = " gsr " ; Console . WriteLine ( checkPattern ( str , pattern ) ) ; } }
Calculate sum of all numbers present in a string | C # program to calculate sum of all numbers present in a string containing alphanumeric characters ; Function to calculate sum of all numbers present in a string containing alphanumeric characters ; A temporary string ; holds sum of all numbers present in the string ; read each character in input string ; if current character is a digit ; if current character is an alphabet ; increment sum by number found earlier ( if any ) ; reset temporary string to empty ; atoi ( temp . c_str ( ) ) takes care of trailing numbers ; Driver code ; input alphanumeric string ; Function call
using System ; class GFG { static int findSum ( String str ) { String temp = "0" ; int sum = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { char ch = str [ i ] ; if ( char . IsDigit ( ch ) ) temp += ch ; else { sum += int . Parse ( temp ) ; temp = "0" ; } } return sum + int . Parse ( temp ) ; } public static void Main ( String [ ] args ) { String str = "12abc20yz68" ; Console . WriteLine ( findSum ( str ) ) ; } }
Count number of substrings with exactly k distinct characters | C # program to CountKSubStr number of substrings with exactly distinct characters in a given string ; Function to count number of substrings with exactly k unique characters ; Initialize result ; To store count of characters from ' a ' to ' z ' ; Consider all substrings beginning with str [ i ] ; Initializing count array with 0 ; Consider all substrings between str [ i . . j ] ; If this is a new character for this substring , increment dist_count . ; Increment count of current character ; If distinct character count becomes k , then increment result . ; Driver Program
using System ; public class CountKSubStr { int countkDist ( string str , int k ) { int res = 0 ; int n = str . Length ; int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { int dist_count = 0 ; Array . Clear ( cnt , 0 , cnt . Length ) ; for ( int j = i ; j < n ; j ++ ) { if ( cnt [ str [ j ] - ' a ' ] == 0 ) dist_count ++ ; cnt [ str [ j ] - ' a ' ] ++ ; if ( dist_count == k ) res ++ ; } } return res ; } public static void Main ( ) { CountKSubStr ob = new CountKSubStr ( ) ; string ch = " abcbaa " ; int k = 3 ; Console . Write ( " Total ▁ substrings ▁ with ▁ exactly ▁ " + k + " ▁ distinct ▁ characters ▁ : ▁ " + ob . countkDist ( ch , k ) ) ; } }
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 [ ] In ) { for ( int i = 0 ; i < In . Length ; i ++ ) { if ( ' a ' <= In [ i ] & In [ i ] <= ' z ' ) { In [ i ] = ( char ) ( In [ i ] - ' a ' + ' A ' ) ; } } return String . Join ( " " , In ) ; } public static void Main ( ) { String str = " geeksforgeeks " ; Console . WriteLine ( to_upper ( str . ToCharArray ( ) ) ) ; } }
Longest Common Prefix using Character by Character Matching | A C # Program to find the longest common prefix ; 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 ; Our resultant string char current ; The current character ; Current character ( must be same in all strings to be a part of result ) ; Append to result ; Driver code
using System ; class GFG { static int findMinLength ( String [ ] arr , int n ) { int min = arr [ 0 ] . Length ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] . Length < min ) { min = arr [ i ] . Length ; } } return ( min ) ; } static String commonPrefix ( String [ ] arr , int n ) { int minlen = findMinLength ( arr , n ) ; String result = " " ; for ( int i = 0 ; i < minlen ; i ++ ) { current = arr [ 0 ] [ i ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( arr [ j ] [ i ] != current ) { return result ; } } result += ( current ) ; } return ( result ) ; } public static void Main ( String [ ] args ) { 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 " ) ; } } }
Print Concatenation of Zig | C # program to print string obtained by concatenation of different rows of Zig - Zag fashion ; Prints concatenation of all rows of str 's  Zig-Zag fashion ; Corner Case ( Only one row ) ; Find length of string ; Create an array of strings for all n rows ; Initialize index for array of strings arr [ ] ; True if we are moving down in rows , else false ; Traverse through given string ; append current character to current row ; If last row is reached , change direction to ' up ' ; If 1 st row is reached , change direction to ' down ' ; If direction is down , increment , else decrement ; Print concatenation of all rows ; Driver Code
using System ; class GFG { static void printZigZagConcat ( string str , int n ) { if ( n == 1 ) { Console . Write ( str ) ; return ; } char [ ] str1 = str . ToCharArray ( ) ; int len = str . Length ; string [ ] arr = new string [ n ] ; int row = 0 ; bool down = true ; for ( int i = 0 ; i < len ; ++ i ) { arr [ row ] += ( str1 [ i ] ) ; if ( row == n - 1 ) down = false ; else if ( row == 0 ) down = true ; if ( down ) row ++ ; else row -- ; } for ( int i = 0 ; i < n ; ++ i ) Console . Write ( arr [ i ] ) ; } public static void Main ( ) { String str = " GEEKSFORGEEKS " ; int n = 3 ; printZigZagConcat ( str , n ) ; } }
Check if two given strings are isomorphic to each other | C # program to check if two strings are isomorphic ; Function returns true if str1 and str2 are isomorphic ; Length of both strings must be same for one to one corresponance ; To mark visited characters in str2 ; To store mapping of every character from str1 to that of str2 and Initialize all entries of map as - 1. ; Process all characters one by on ; If current character of str1 is seen first time in it . ; If current character of str2 is already seen , one to one mapping not possible ; Mark current character of str2 as visited ; Store mapping of current characters ; If this is not first appearance of current character in str1 , then check if previous appearance mapped to same character of str2 ; Driver code
using System ; class GFG { static int size = 256 ; static bool areIsomorphic ( String str1 , String str2 ) { int m = str1 . Length ; int n = str2 . Length ; if ( m != n ) return false ; bool [ ] marked = new bool [ size ] ; for ( int i = 0 ; i < size ; i ++ ) marked [ i ] = false ; int [ ] map = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) map [ i ] = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( map [ str1 [ i ] ] == - 1 ) { if ( marked [ str2 [ i ] ] == true ) return false ; marked [ str2 [ i ] ] = true ; map [ str1 [ i ] ] = str2 [ i ] ; } else if ( map [ str1 [ i ] ] != str2 [ i ] ) return false ; } return true ; } public static void Main ( ) { bool res = areIsomorphic ( " aab " , " xxy " ) ; Console . WriteLine ( res ) ; res = areIsomorphic ( " aab " , " xyz " ) ; Console . WriteLine ( res ) ; } }
Check if two given strings are isomorphic to each other | C # program for the above approach ; This function returns true if str1 and str2 are isomorphic ; Length of both strings must be same for one to one correspondence ; For counting the previous appearances of character in both the strings ; Process all characters one by one ; For string to be isomorphic the previous counts of appearances of current character in both string must be same if it is not same we return false . ; Driver Code
using System ; class GFG { static int CHAR = 26 ; static bool isoMorphic ( string str1 , string str2 ) { int n = str1 . Length ; int m = str2 . Length ; if ( n != m ) return false ; int [ ] countChars1 = new int [ CHAR ] ; int [ ] countChars2 = new int [ CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { countChars1 [ str1 [ i ] - ' a ' ] ++ ; countChars2 [ str2 [ i ] - ' a ' ] ++ ; if ( countChars1 [ str1 [ i ] - ' a ' ] != countChars2 [ str2 [ i ] - ' a ' ] ) { return false ; } } return true ; } public static void Main ( string [ ] args ) { Console . WriteLine ( isoMorphic ( " aab " , " xxy " ) ? 1 : 0 ) ; Console . WriteLine ( isoMorphic ( " aab " , " xyz " ) ? 1 : 0 ) ; } }
Minimum insertions to form shortest palindrome | C # program to find minimum number of insertions on left side to form a palindrome . ; Returns true if a string str [ st . . end ] is palindrome ; Returns count of insertions on left side to make str [ ] a palindrome ; Find the largest prefix of given string that is palindrome . ; Characters after the palindromic prefix must be added at the beginning also to make the complete string palindrome ; Driver Code
using System ; using System . Text ; class GFG { static bool isPalin ( char [ ] str , int st , int end ) { while ( st < end ) { if ( str [ st ] != str [ end ] ) return false ; st ++ ; end -- ; } return true ; } static int findMinInsert ( char [ ] str , int n ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( isPalin ( str , 0 , i ) ) return ( n - i - 1 ) ; } return 0 ; } public static void Main ( string [ ] args ) { char [ ] Input = " JAVA " . ToCharArray ( ) ; Console . Write ( findMinInsert ( Input , Input . Length ) ) ; } }
Remove repeated digits in a given number | C # program to remove repeated digits ; Store first digits as previous digit ; Initialize power ; Iterate through all digits of n , note that the digits are processed from least significant digit to most significant digit . ; Store current digit ; Add the current digit to the beginning of result ; Update previous result and power ; Remove last digit from n ; Driver program
using System ; class GFG { static long removeRecur ( long n ) { long prev_digit = n % 10 ; long pow = 10 ; long res = prev_digit ; while ( n > 0 ) { long curr_digit = n % 10 ; if ( curr_digit != prev_digit ) { res += curr_digit * pow ; prev_digit = curr_digit ; pow *= 10 ; } n = n / 10 ; } return res ; } public static void Main ( ) { long n = 12224 ; Console . WriteLine ( removeRecur ( n ) ) ; } }