codeparrot/xlcost-text-to-code huggingface dataset:
Modify given array to a non | C # program to implement the above approach ; Function to check if a non - decreasing array can be obtained by rotating the original array ; Stores copy of original array ; Sort the given vector ; Traverse the array ; Rotate the array by 1 ; If array is sorted ; If it is not possible to sort the array ; Driver code ; Given array ; Size of the array ; Function call to check if it is possible to make array non - decreasing by rotating
using System ; class GFG { static void rotateArray ( int [ ] arr , int N ) { int [ ] v = arr ; Array . Sort ( v ) ; for ( int i = 1 ; i <= N ; ++ i ) { int x = arr [ N - 1 ] ; i = N - 1 ; while ( i > 0 ) { arr [ i ] = arr [ i - 1 ] ; arr [ 0 ] = x ; i -= 1 ; } if ( arr == v ) { Console . Write ( " YES " ) ; return ; } } Console . Write ( " NO " ) ; } public static void Main ( ) { int [ ] arr = { 3 , 4 , 5 , 1 , 2 } ; int N = arr . Length ; rotateArray ( arr , N ) ; } }
Maximum value possible by rotating digits of a given number | C # program for the above approach ; Function to find the maximum value possible by rotations of digits of N ; Store the required result ; Store the number of digits ; Iterate over the range [ 1 , len - 1 ] ; Store the unit 's digit ; Store the remaining number ; Find the next rotation ; If the current rotation is greater than the overall answer , then update answer ; Print the result ; Driver Code
using System ; class GFG { static void findLargestRotation ( int num ) { int ans = num ; double lg = ( double ) ( Math . Log10 ( num ) + 1 ) ; int len = ( int ) ( Math . Floor ( lg ) ) ; int x = ( int ) Math . Pow ( 10 , len - 1 ) ; for ( int i = 1 ; i < len ; i ++ ) { int lastDigit = num % 10 ; num = num / 10 ; num += ( lastDigit * x ) ; if ( num > ans ) { ans = num ; } } Console . Write ( ans ) ; } public static void Main ( string [ ] args ) { int N = 657 ; findLargestRotation ( N ) ; } }
Rotate digits of a given number by K | C # program to implement the above approach ; Function to find the count of digits in N ; Stores count of digits in N ; Calculate the count of digits in N ; Update digit ; Update N ; Function to rotate the digits of N by K ; Stores count of digits in N ; Update K so that only need to handle left rotation ; Stores first K digits of N ; Remove first K digits of N ; Stores count of digits in left_no ; Append left_no to the right of digits of N ; Driver Code ; Function Call
using System ; class GFG { static int numberOfDigit ( int N ) { int digit = 0 ; while ( N > 0 ) { digit ++ ; N /= 10 ; } return digit ; } static void rotateNumberByK ( int N , int K ) { int X = numberOfDigit ( N ) ; K = ( ( K % X ) + X ) % X ; int left_no = N / ( int ) ( Math . Pow ( 10 , X - K ) ) ; N = N % ( int ) ( Math . Pow ( 10 , X - K ) ) ; int left_digit = numberOfDigit ( left_no ) ; N = ( N * ( int ) ( Math . Pow ( 10 , left_digit ) ) ) + left_no ; Console . WriteLine ( N ) ; } public static void Main ( string [ ] args ) { int N = 12345 , K = 7 ; rotateNumberByK ( N , K ) ; } }
Count rotations required to sort given array in non | C # program for the above approach ; Function to count minimum anti - clockwise rotations required to sort the array in non - increasing order ; Stores count of arr [ i + 1 ] > arr [ i ] ; Store last index of arr [ i + 1 ] > arr [ i ] ; Traverse the given array ; If the adjacent elements are in increasing order ; Increment count ; Update index ; Print the result according to the following conditions ; Otherwise , it is not possible to sort the array ; Driver Code ; Given array ; Function Call
using System ; class GFG { static void minMovesToSort ( int [ ] arr , int N ) { int count = 0 ; int index = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) { count ++ ; index = i ; } } if ( count == 0 ) { Console . Write ( "0" ) ; } else if ( count == N - 1 ) { Console . Write ( N - 1 ) ; } else if ( count == 1 && arr [ 0 ] <= arr [ N - 1 ] ) { Console . Write ( index + 1 ) ; } else { Console . Write ( " - 1" ) ; } } public static void Main ( ) { int [ ] arr = { 2 , 1 , 5 , 4 , 2 } ; int N = arr . Length ; minMovesToSort ( arr , N ) ; } }
Maximize sum of diagonal of a matrix by rotating all rows or all columns | C # program to implement the above approach ; Function to find maximum sum of diagonal elements of matrix by rotating either rows or columns ; Stores maximum diagonal sum of elements of matrix by rotating rows or columns ; Rotate all the columns by an integer in the range [ 0 , N - 1 ] ; Stores sum of diagonal elements of the matrix ; Calculate sum of diagonal elements of the matrix ; Update curr ; Update maxDiagonalSum ; Rotate all the rows by an integer in the range [ 0 , N - 1 ] ; Stores sum of diagonal elements of the matrix ; Calculate sum of diagonal elements of the matrix ; Update curr ; Update maxDiagonalSum ; Driver Code
using System ; class GFG { static int N = 3 ; static int findMaximumDiagonalSumOMatrixf ( int [ , ] A ) { int maxDiagonalSum = Int32 . MinValue ; for ( int i = 0 ; i < N ; i ++ ) { int curr = 0 ; for ( int j = 0 ; j < N ; j ++ ) { curr += A [ j , ( i + j ) % N ] ; } maxDiagonalSum = Math . Max ( maxDiagonalSum , curr ) ; } for ( int i = 0 ; i < N ; i ++ ) { int curr = 0 ; for ( int j = 0 ; j < N ; j ++ ) { curr += A [ ( i + j ) % N , j ] ; } maxDiagonalSum = Math . Max ( maxDiagonalSum , curr ) ; } return maxDiagonalSum ; } public static void Main ( ) { int [ , ] mat = { { 1 , 1 , 2 } , { 2 , 1 , 2 } , { 1 , 2 , 2 } } ; Console . Write ( findMaximumDiagonalSumOMatrixf ( mat ) ) ; } }
Generate a matrix having sum of secondary diagonal equal to a perfect square | C # program for the above approach ; Function to print the matrix whose sum of element in secondary diagonal is a perfect square ; Iterate for next N - 1 rows ; Print the current row after the left shift ; Driver Code ; Given N ; Fill the array with elements ranging from 1 to N ; Function Call
using System ; class GFG { static void diagonalSumPerfectSquare ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { Console . Write ( arr [ ( j + i ) % 7 ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] srgs ) { int N = 7 ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = i + 1 ; } diagonalSumPerfectSquare ( arr , N ) ; } }
Queries to find maximum sum contiguous subarrays of given length in a rotating array | C # program for the above approach ; Function to calculate the maximum sum of length k ; Calculating the max sum for the first k elements ; Find subarray with maximum sum ; Update the sum ; Return maximum sum ; Function to calculate gcd of the two numbers n1 and n2 ; Base Case ; Recursively find the GCD ; Function to rotate the array by Y ; For handling k >= N ; Dividing the array into number of sets ; Rotate the array by Y ; Update arr [ j ] ; Return the rotated array ; Function that performs the queries on the given array ; Traverse each query ; If query of type X = 1 ; Print the array ; If query of type X = 2 ; Driver code ; Given array arr [ ] ; Given Queries ; Function call
using System ; class GFG { static int MaxSum ( int [ ] arr , int n , int k ) { int i , max_sum = 0 , sum = 0 ; for ( i = 0 ; i < k ; i ++ ) { sum += arr [ i ] ; } max_sum = sum ; while ( i < n ) { sum = sum - arr [ i - k ] + arr [ i ] ; if ( max_sum < sum ) { max_sum = sum ; } i ++ ; } return max_sum ; } static int gcd ( int n1 , int n2 ) { if ( n2 == 0 ) { return n1 ; } else { return gcd ( n2 , n1 % n2 ) ; } } static int [ ] RotateArr ( int [ ] arr , int n , int d ) { int i = 0 , j = 0 ; d = d % n ; int no_of_sets = gcd ( d , n ) ; for ( i = 0 ; i < no_of_sets ; i ++ ) { int temp = arr [ i ] ; j = i ; while ( true ) { int k = j + d ; if ( k >= n ) k = k - n ; if ( k == i ) break ; arr [ j ] = arr [ k ] ; j = k ; } arr [ j ] = temp ; } return arr ; } static void performQuery ( int [ ] arr , int [ , ] Q , int q ) { int N = arr . Length ; for ( int i = 0 ; i < q ; i ++ ) { if ( Q [ i , 0 ] == 1 ) { arr = RotateArr ( arr , N , Q [ i , 1 ] ) ; for ( int t = 0 ; t < arr . Length ; t ++ ) { Console . Write ( arr [ t ] + " ▁ " ) ; } Console . WriteLine ( ) ; } else { Console . WriteLine ( MaxSum ( arr , N , Q [ i , 1 ] ) ) ; } } } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int q = 5 ; int [ , ] Q = { { 1 , 2 } , { 2 , 3 } , { 1 , 3 } , { 1 , 1 } , { 2 , 4 } } ; performQuery ( arr , Q , q ) ; } }
Minimize characters to be changed to make the left and right rotation of a string same | C # program of the above approach ; Function to find the minimum characters to be removed from the string ; Initialize answer by N ; If length is even ; Frequency array for odd and even indices ; Store the frequency of the characters at even and odd indices ; Stores the most occuring frequency for even and odd indices ; Update the answer ; If length is odd ; Stores the frequency of the characters of the string ; Stores the most occuring character in the string ; Update the answer ; Driver code
using System ; class GFG { public static int getMinimumRemoval ( String str ) { int n = str . Length ; int ans = n ; if ( n % 2 == 0 ) { int [ ] freqEven = new int [ 128 ] ; int [ ] freqOdd = new int [ 128 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { freqEven [ str [ i ] ] ++ ; } else { freqOdd [ str [ i ] ] ++ ; } } int evenMax = 0 , oddMax = 0 ; for ( char chr = ' a ' ; chr <= ' z ' ; chr ++ ) { evenMax = Math . Max ( evenMax , freqEven [ chr ] ) ; oddMax = Math . Max ( oddMax , freqOdd [ chr ] ) ; } ans = ans - evenMax - oddMax ; } else { int [ ] freq = new int [ 128 ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] ] ++ ; } int strMax = 0 ; for ( char chr = ' a ' ; chr <= ' z ' ; chr ++ ) { strMax = Math . Max ( strMax , freq [ chr ] ) ; } ans = ans - strMax ; } return ans ; } public static void Main ( String [ ] args ) { String str = " geeksgeeks " ; Console . Write ( getMinimumRemoval ( str ) ) ; } }
Longest subsequence of a number having same left and right rotation | C # Program to implement the above approach ; Function to find the longest subsequence having equal left and right rotation ; Length of the String ; Iterate for all possible combinations of a two - digit numbers ; Check for alternate occurrence of current combination ; Increment the current value ; Increment the current value ; If alternating sequence is obtained of odd length ; Reduce to even length ; Update answer to store the maximum ; Return the answer ; Driver Code
using System ; class GFG { static int findAltSubSeq ( String s ) { int n = s . Length , ans = int . MinValue ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { int cur = 0 , f = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( f == 0 && s [ k ] - '0' == i ) { f = 1 ; cur ++ ; } else if ( f == 1 && s [ k ] - '0' == j ) { f = 0 ; cur ++ ; } } if ( i != j && cur % 2 == 1 ) cur -- ; ans = Math . Max ( cur , ans ) ; } } return ans ; } public static void Main ( String [ ] args ) { String s = "100210601" ; Console . Write ( findAltSubSeq ( s ) ) ; } }
Rotate matrix by 45 degrees | C # program for the above approach ; Function to rotate matrix by 45 degree ; Counter Variable ; Iterate [ 0 , m ] ; Iterate [ 0 , n ] ; Diagonal Elements Condition ; Appending the Diagonal Elements ; Printing reversed Diagonal Elements ; Driver code ; Dimensions of Matrix ; Given matrix ; Function call
using System ; using System . Collections ; class GFG { static void matrix ( int n , int m , int [ , ] li ) { int ctr = 0 ; while ( ctr < 2 * n - 1 ) { for ( int i = 0 ; i < Math . Abs ( n - ctr - 1 ) ; i ++ ) { Console . Write ( " ▁ " ) ; } ArrayList lst = new ArrayList ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i + j == ctr ) { lst . Add ( li [ i , j ] ) ; } } } for ( int i = lst . Count - 1 ; i >= 0 ; i -- ) { Console . Write ( ( int ) lst [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; ctr += 1 ; } } public static void Main ( string [ ] args ) { int n = 8 ; int m = n ; int [ , ] li = { { 4 , 5 , 6 , 9 , 8 , 7 , 1 , 4 } , { 1 , 5 , 9 , 7 , 5 , 3 , 1 , 6 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 0 } , { 6 , 5 , 4 , 7 , 8 , 9 , 3 , 7 } , { 3 , 5 , 6 , 4 , 8 , 9 , 2 , 1 } , { 3 , 1 , 6 , 4 , 7 , 9 , 5 , 0 } , { 8 , 0 , 7 , 2 , 3 , 1 , 0 , 8 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 5 } } ; matrix ( n , m , li ) ; } }
Mth element after K Right Rotations of an Array | C # program to implement the above approach ; Function to return Mth element of array after k right rotations ; The array comes to original state after N rotations ; If K is greater or equal to M ; Mth element after k right rotations is ( N - K ) + ( M - 1 ) th element of the array ; Otherwise ; ( M - K - 1 ) th element of the array ; Return the result ; Driver Code
using System ; class GFG { static int getFirstElement ( int [ ] a , int N , int K , int M ) { K %= N ; int index ; if ( K >= M ) index = ( N - K ) + ( M - 1 ) ; else index = ( M - K - 1 ) ; int result = a [ index ] ; return result ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 , 4 , 5 } ; int N = 5 ; int K = 3 , M = 2 ; Console . Write ( getFirstElement ( a , N , K , M ) ) ; } }
Find the Mth element of the Array after K left rotations | C # program for the above approach ; Function to return Mth element of array after k left rotations ; The array comes to original state after N rotations ; Mth element after k left rotations is ( K + M - 1 ) % N th element of the original array ; Return the result ; Driver code ; Array initialization ; Size of the array ; Given K rotation and Mth element to be found after K rotation ; Function call
using System ; class GFG { public static int getFirstElement ( int [ ] a , int N , int K , int M ) { K %= N ; int index = ( K + M - 1 ) % N ; int result = a [ index ] ; return result ; } public static void Main ( string [ ] args ) { int [ ] a = { 3 , 4 , 5 , 23 } ; int N = a . Length ; int K = 2 , M = 1 ; Console . Write ( getFirstElement ( a , N , K , M ) ) ; } }
Rotate all odd numbers right and all even numbers left in an Array of 1 to N | C # program to implement the above approach ; Function to left rotate ; Function to right rotate ; Function to rotate the array ; Driver code
using System ; class GFG { static void left_rotate ( int [ ] arr ) { int last = arr [ 1 ] ; for ( int i = 3 ; i < arr . Length ; i = i + 2 ) { arr [ i - 2 ] = arr [ i ] ; } arr [ arr . Length - 1 ] = last ; } static void right_rotate ( int [ ] arr ) { int start = arr [ arr . Length - 2 ] ; for ( int i = arr . Length - 4 ; i >= 0 ; i = i - 2 ) { arr [ i + 2 ] = arr [ i ] ; } arr [ 0 ] = start ; } public static void rotate ( int [ ] arr ) { left_rotate ( arr ) ; right_rotate ( arr ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; rotate ( arr ) ; } }
Maximize count of corresponding same elements in given permutations using cyclic rotations | C # program for the above approach ; Function to maximize the matching pairs between two permutation using left and right rotation ; Left array store distance of element from left side and right array store distance of element from right side ; Map to store index of elements ; idx1 is index of element in first permutation idx2 is index of element in second permutation ; If element if present on same index on both permutations then distance is zero ; Calculate distance from left and right side ; Calculate distance from left and right side ; Maps to store frequencies of elements present in left and right arrays ; Find maximum frequency ; Return the result ; Driver Code ; Given permutations P1 and P2 ; Function Call
using System ; using System . Collections . Generic ; class GFG { static int maximumMatchingPairs ( int [ ] perm1 , int [ ] perm2 , int n ) { int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; Dictionary < int , int > mp1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > mp2 = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { mp1 [ perm1 [ i ] ] = i ; } for ( int j = 0 ; j < n ; j ++ ) { mp2 [ perm2 [ j ] ] = j ; } for ( int i = 0 ; i < n ; i ++ ) { int idx2 = mp2 [ perm1 [ i ] ] ; int idx1 = i ; if ( idx1 == idx2 ) { left [ i ] = 0 ; right [ i ] = 0 ; } else if ( idx1 < idx2 ) { left [ i ] = ( n - ( idx2 - idx1 ) ) ; right [ i ] = ( idx2 - idx1 ) ; } else { left [ i ] = ( idx1 - idx2 ) ; right [ i ] = ( n - ( idx1 - idx2 ) ) ; } } Dictionary < int , int > freq1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > freq2 = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq1 . ContainsKey ( left [ i ] ) ) freq1 [ left [ i ] ] ++ ; else freq1 [ left [ i ] ] = 1 ; if ( freq2 . ContainsKey ( right [ i ] ) ) freq2 [ right [ i ] ] ++ ; else freq2 [ right [ i ] ] = 1 ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . Max ( ans , Math . Max ( freq1 [ left [ i ] ] , freq2 [ right [ i ] ] ) ) ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] P1 = { 5 , 4 , 3 , 2 , 1 } ; int [ ] P2 = { 1 , 2 , 3 , 4 , 5 } ; int n = P1 . Length ; Console . Write ( maximumMatchingPairs ( P1 , P2 , n ) ) ; } }
Count of rotations required to generate a sorted array | C # program to find the count of rotations ; Function to return the count of rotations ; Find the smallest element ; Return its index ; If array is not rotated at all ; Driver Code
using System ; class GFG { public static int countRotation ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { return i ; } } return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 4 , 5 , 1 , 2 , 3 } ; Console . WriteLine ( countRotation ( arr1 , arr1 . Length ) ) ; } }
Count of rotations required to generate a sorted array | C # program to implement the above approach ; Function to return the count of rotations ; If array is not rotated ; Check if current element is greater than the next element ; The next element is the smallest ; Check if current element is smaller than it 's previous  element ; Current element is the smallest ; Check if current element is greater than lower bound ; The sequence is increasing so far Search for smallest element on the right subarray ; Smallest element lies on the left subarray ; Search for the smallest element on both subarrays ; Driver code
using System ; class GFG { public static int countRotation ( int [ ] arr , int low , int high ) { if ( low > high ) { return 0 ; } int mid = low + ( high - low ) / 2 ; if ( mid < high && arr [ mid ] > arr [ mid + 1 ] ) { return mid + 1 ; } if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) { return mid ; } if ( arr [ mid ] > arr [ low ] ) { return countRotation ( arr , mid + 1 , high ) ; } if ( arr [ mid ] < arr [ high ] ) { return countRotation ( arr , low , mid - 1 ) ; } else { int rightIndex = countRotation ( arr , mid + 1 , high ) ; int leftIndex = countRotation ( arr , low , mid - 1 ) ; if ( rightIndex == 0 ) { return leftIndex ; } return rightIndex ; } } public static void Main ( String [ ] args ) { int [ ] arr1 = { 4 , 5 , 1 , 2 , 3 } ; Console . WriteLine ( countRotation ( arr1 , 0 , arr1 . Length - 1 ) ) ; } }
Range sum queries for anticlockwise rotations of Array by K indices | C # program to calculate range sum queries for anticlockwise rotations of array by K ; Function to execute the queries ; Construct a new array of size 2 * N to store prefix sum of every index ; Copy elements to the new array ; Calculate the prefix sum for every index ; Set start pointer as 0 ; Query to perform anticlockwise rotation ; Query to answer range sum ; If pointing to 1 st index ; Display the sum upto start + R ; Subtract sum upto start + L - 1 from sum upto start + R ; Driver code ; Number of query ; Store all the queries
using System ; class GFG { static void rotatedSumQuery ( int [ ] arr , int n , int [ , ] query , int Q ) { int [ ] prefix = new int [ 2 * n ] ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i ] = arr [ i ] ; prefix [ i + n ] = arr [ i ] ; } for ( int i = 1 ; i < 2 * n ; i ++ ) prefix [ i ] += prefix [ i - 1 ] ; int start = 0 ; for ( int q = 0 ; q < Q ; q ++ ) { if ( query [ q , 0 ] == 1 ) { int k = query [ q , 1 ] ; start = ( start + k ) % n ; } else if ( query [ q , 0 ] == 2 ) { int L , R ; L = query [ q , 1 ] ; R = query [ q , 2 ] ; if ( start + L == 0 ) Console . Write ( prefix [ start + R ] + " STRNEWLINE " ) ; else Console . Write ( prefix [ start + R ] - prefix [ start + L - 1 ] + " STRNEWLINE " ) ; } } } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 , 6 } ; int Q = 5 ; int [ , ] query = new int [ , ] { { 2 , 1 , 3 } , { 1 , 3 , 0 } , { 2 , 0 , 3 } , { 1 , 4 , 0 } , { 2 , 3 , 5 } } ; int n = arr . Length ; rotatedSumQuery ( arr , n , query , Q ) ; } }
Check if a string can be formed from another string by at most X circular clockwise shifts | C # implementation to check that a given string can be converted to another string by circular clockwise shift of each character by atmost X times ; Function to check that all characters of s1 can be converted to s2 by circular clockwise shift atmost X times ; Check for all characters of the strings whether the difference between their ascii values is less than X or not ; If both the characters are same ; Calculate the difference between the ASCII values of the characters ; If difference exceeds X ; Driver Code ; Function call
using System ; class GFG { static void isConversionPossible ( String s1 , String s2 , int x ) { int diff = 0 , n ; n = s1 . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 [ i ] == s2 [ i ] ) continue ; diff = ( ( int ) ( s2 [ i ] - s1 [ i ] ) + 26 ) % 26 ; if ( diff > x ) { Console . Write ( " NO " ) ; return ; } } Console . Write ( " YES " ) ; } public static void Main ( ) { String s1 = " you " ; String s2 = " ara " ; int x = 6 ; isConversionPossible ( s1 , s2 , x ) ; } }
Count rotations which are divisible by 10 | CSharp implementation to find the count of rotations which are divisible by 10 ; Function to return the count of all rotations which are divisible by 10. ; Loop to iterate through the number ; If the last digit is 0 , then increment the count ; Driver code
using System ; class Solution { static int countRotation ( int n ) { int count = 0 ; do { int digit = n % 10 ; if ( digit % 2 == 0 ) count ++ ; n = n / 10 ; } while ( n != 0 ) ; return count ; } public static void Main ( ) { int n = 10203 ; Console . Write ( countRotation ( n ) ) ; } }