codeparrot/xlcost-text-to-code huggingface dataset:
Rearrange a string S1 such that another given string S2 is not its subsequence | Java program for the above approach ; Function to rearrange characters in string S1 such that S2 is not a subsequence of it ; Store the frequencies of characters of string s2 ; Traverse the string s2 ; Update the frequency ; Find the number of unique characters in s2 ; Increment unique by 1 if the condition satisfies ; Check if the number of unique characters in string s2 is 1 ; Store the unique character frequency ; Store occurence of it in s1 ; Find count of that character in the string s1 ; Increment count by 1 if that unique character is same as current character ; If count count_in_s1 is less than count_in_s2 , then print s1 and return ; Otherwise , there is no possible arrangement ; Checks if any character in s2 is less than its next character ; Iterate the string , s2 ; If s [ i ] is greater than the s [ i + 1 ] ; Set inc to 0 ; If inc = 1 , print s1 in decreasing order ; Otherwise , print s1 in increasing order ; Driver code
import java . util . * ; class GFG { static void rearrangeString ( char [ ] s1 , char [ ] s2 ) { int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < s2 . length ; i ++ ) cnt [ s2 [ i ] - ' a ' ] ++ ; int unique = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) if ( cnt [ i ] != 0 ) unique ++ ; if ( unique == 1 ) { int count_in_s2 = s2 . length ; int count_in_s1 = 0 ; for ( int i = 0 ; i < s1 . length ; i ++ ) if ( s1 [ i ] == s2 [ 0 ] ) count_in_s1 ++ ; if ( count_in_s1 < count_in_s2 ) { System . out . print ( new String ( s1 ) ) ; return ; } System . out . print ( - 1 ) ; } else { int inc = 1 ; for ( int i = 0 ; i < s2 . length - 1 ; i ++ ) if ( s2 [ i ] > s2 [ i + 1 ] ) inc = 0 ; if ( inc == 1 ) { Arrays . sort ( s1 ) ; for ( int k = 0 ; k < s1 . length / 2 ; k ++ ) { char temp = s1 [ k ] ; s1 [ k ] = s1 [ s1 . length - k - 1 ] ; s1 [ s1 . length - k - 1 ] = temp ; } System . out . print ( new String ( s1 ) ) ; } else { Arrays . sort ( s1 ) ; System . out . print ( new String ( s1 ) ) ; } } } public static void main ( String [ ] args ) { char [ ] s1 = " abcd " . toCharArray ( ) ; char [ ] s2 = " ab " . toCharArray ( ) ; rearrangeString ( s1 , s2 ) ; } }
Check if a string can be emptied by removing all subsequences of the form "10" | Java program for the above approach ; Function to find if string is reducible to NULL ; Length of string ; Stack to store all 1 s ; Iterate over the characters of the string ; If current character is 1 ; Push it into the stack ; Pop from the stack ; If the stack is empty ; Driver code
import java . io . * ; import java . util . * ; class GFG { static boolean isReducible ( String str ) { int N = str . length ( ) ; ArrayList < Character > s = new ArrayList < Character > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == '1' ) s . add ( str . charAt ( i ) ) ; else if ( s . size ( ) > 0 ) s . remove ( s . size ( ) - 1 ) ; else return false ; } if ( s . size ( ) == 0 ) { return true ; } else { return false ; } } public static void main ( String [ ] args ) { String str = "11011000" ; if ( isReducible ( str ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }
Minimize flips required such that string does not any pair of consecutive 0 s | Java program for the above approach ; Function to find minimum flips required such that a String does not contain any pair of consecutive 0 s ; Stores minimum count of flips ; Iterate over the characters of the String ; If two consecutive characters are equal to '0' ; Update S [ i + 1 ] ; Update cntOp ; Driver Code
import java . util . * ; class GFG { static int cntMinOperation ( char [ ] S , int N ) { int cntOp = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( S [ i ] == '0' && S [ i + 1 ] == '0' ) { S [ i + 1 ] = '1' ; cntOp += 1 ; } } return cntOp ; } public static void main ( String [ ] args ) { String S = "10001" ; int N = S . length ( ) ; System . out . print ( cntMinOperation ( S . toCharArray ( ) , N ) ) ; } }
Rearrange a string to maximize the minimum distance between any pair of vowels | Java program for the above approach ; Function to rearrange the String such that the minimum distance between any of vowels is maximum . ; Store vowels and consonants ; Iterate over the characters of String ; If current character is a vowel ; If current character is a consonant ; Stores count of vowels and consonants respectively ; Stores the resultant String ; Stores count of consonants appended into ans ; Append vowel to ans ; Append consonants ; Append consonant to ans ; Update temp ; Remove the taken elements of consonant ; Return final ans ; Driver Code ; Function Call
import java . util . * ; class GFG { static String solution ( String s ) { Vector < Character > vowel = new Vector < Character > ( ) ; Vector < Character > consonant = new Vector < Character > ( ) ; for ( char i : s . toCharArray ( ) ) { if ( i == ' a ' i == ' e ' i == ' i ' i == ' o ' i == ' u ' ) { vowel . add ( i ) ; } else { consonant . add ( i ) ; } } int Nc , Nv ; Nv = vowel . size ( ) ; Nc = consonant . size ( ) ; int M = Nc / ( Nv - 1 ) ; String ans = " " ; int consotnant_till = 0 ; for ( char i : vowel ) { ans += i ; int temp = 0 ; for ( int j = consotnant_till ; j < Math . min ( Nc , consotnant_till + M ) ; j ++ ) { ans += consonant . get ( j ) ; temp ++ ; } consotnant_till += temp ; } return ans ; } public static void main ( String [ ] args ) { String str = " aaaabbbcc " ; System . out . print ( solution ( str ) ) ; } }
Lexicographically smallest string possible by performing K operations on a given string | Java program to implement the above approach ; Function to find the lexicographically smallest possible string by performing K operations on string S ; Store the size of string , s ; Check if k >= n , if true , convert every character to ' a ' ; Iterate in range [ 0 , n - 1 ] using i ; When k reaches 0 , break the loop ; If current character is ' a ' , continue ; Otherwise , iterate in the range [ i + 1 , n - 1 ] using j ; Check if s [ j ] > s [ i ] ; If true , set s [ j ] = s [ i ] and break out of the loop ; Check if j reaches the last index ; Update S [ i ] ; Decrement k by 1 ; Print string ; Driver code ; Given String , s ; Given k ; Function Call
public class GFG { static void smallestlexicographicstring ( char [ ] s , int k ) { int n = s . length ; if ( k >= n ) { for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = ' a ' ; } System . out . print ( s ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { if ( k == 0 ) { break ; } if ( s [ i ] == ' a ' ) continue ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( s [ j ] > s [ i ] ) { s [ j ] = s [ i ] ; break ; } else if ( j == n - 1 ) s [ j ] = s [ i ] ; } s [ i ] = ' a ' ; k -- ; } System . out . print ( s ) ; } public static void main ( String [ ] args ) { char [ ] s = ( " geeksforgeeks " ) . toCharArray ( ) ; int k = 6 ; smallestlexicographicstring ( s , k ) ; } }
Minimize removal of non | Java program for the above approach ; Function to find minimum count of steps required ot make String S an empty String ; Stores count of occurences ' ( ' ; Stores count of occurences ' ) ' ; Traverse the String , str ; If current character is ' ( ' ; Update count_1 ; Update count_2 ; If all the characters are same , then print - 1 ; If the count of occurence of ' ) ' and ' ( ' are same then print 0 ; If length of String is Odd ; Driver Code ; Given String ; Size of the String ; Function Call
import java . util . * ; class GFG { static void canReduceString ( String S , int N ) { int count_1 = 0 ; int count_2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == ' ( ' ) { count_1 ++ ; } else { count_2 ++ ; } } if ( count_1 == 0 count_2 == 0 ) { System . out . print ( " - 1" + "NEW_LINE"); } else if ( count_1 == count_2 ) { System . out . print ( "0" + "NEW_LINE"); } else if ( N % 2 != 0 ) { System . out . print ( " - 1" ) ; } else { System . out . print ( Math . abs ( count_1 - count_2 ) / 2 ) ; } } public static void main ( String [ ] args ) { String S = " ) ) ) ( ( ( " ; int N = S . length ( ) ; canReduceString ( S , N ) ; } }
Program to construct a DFA which accepts the language L = { aN | N â ‰¥ 1 } | Java program for the above approach ; Function to check whether the String S satisfy the given DFA or not ; Stores the count of characters ; Iterate over the range [ 0 , N ] ; Count and check every element for ' a ' ; If String matches with DFA ; If not matches ; Driver Code ; Function Call
class GFG { static void isAcceptedDFA ( String s , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == ' a ' ) count ++ ; } if ( count == N && count != 0 ) { System . out . print ( " Accepted " ) ; } else { System . out . print ( " Not ▁ Accepted " ) ; } } public static void main ( String [ ] args ) { String S = " aaaaa " ; isAcceptedDFA ( S , S . length ( ) ) ; } }
Maximize palindromic strings of length 3 possible from given count of alphabets | Java program for the above approach ; Function to count maximum number of palindromic String of length 3 ; Stores the final count of palindromic Strings ; Traverse the array ; Increment res by arr [ i ] / 3 , i . e forming String of only i + ' a ' character ; Store remainder ; Increment c1 by one , if current frequency is 1 ; Increment c2 by one , if current frequency is 2 ; Count palindromic Strings of length 3 having the character at the ends different from that present in the middle ; Update c1 and c2 ; Increment res by 2 * c2 / 3 ; Finally print the result ; Driver Code ; Given array ; Function Call
import java . util . * ; class GFG { static void maximum_pallindromic ( int arr [ ] ) { int res = 0 ; int c1 = 0 , c2 = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { res += arr [ i ] / 3 ; arr [ i ] = arr [ i ] % 3 ; if ( arr [ i ] == 1 ) c1 ++ ; else if ( arr [ i ] == 2 ) c2 ++ ; } res += Math . min ( c1 , c2 ) ; int t = Math . min ( c1 , c2 ) ; c1 -= t ; c2 -= t ; res += 2 * ( c2 / 3 ) ; c2 %= 3 ; res += c2 / 2 ; System . out . print ( res ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; maximum_pallindromic ( arr ) ; } }
Find the winner of game of repeatedly removing the first character to empty given string | Java program to implement the above approach ; Function to find the winner of a game of repeatedly removing the first character to empty a String ; Store characters of each String of the array arr [ ] ; Stores count of Strings in arr [ ] ; Traverse the array arr [ ] ; Stores length of current String ; Traverse the String ; Insert arr [ i ] [ j ] ; 1 st Player starts the game ; Stores the player number for the next turn ; Remove 1 st character of current String ; Update player number for the next turn ; Driver Code
import java . util . * ; class GFG { static void find_Winner ( String [ ] arr , int N ) { @ SuppressWarnings ( " unchecked " ) Vector < Character > [ ] Q = new Vector [ N ] ; for ( int i = 0 ; i < Q . length ; i ++ ) Q [ i ] = new Vector < Character > ( ) ; int M = arr . length ; for ( int i = 0 ; i < M ; i ++ ) { int len = arr [ i ] . length ( ) ; for ( int j = 0 ; j < len ; j ++ ) { Q [ i ] . add ( arr [ i ] . charAt ( j ) ) ; } } int player = 0 ; while ( Q [ player ] . size ( ) > 0 ) { int nextPlayer = Q [ player ] . get ( 0 ) - '0' - 1 ; Q [ player ] . remove ( 0 ) ; player = nextPlayer ; } System . out . print ( " Player ▁ " + ( player + 1 ) ) ; } public static void main ( String [ ] args ) { int N = 3 ; String [ ] arr = { "323" , "2" , "2" } ; find_Winner ( arr , N ) ; } }
Longest Substring that can be made a palindrome by swapping of characters | Java program for the above approach ; Function to find the Longest substring that can be made a palindrome by swapping of characters ; Initialize dp array of size 1024 ; Initializeing dp array with length of s ; Initializing mask and res ; Traverse the string ; Find the mask of the current character ; Finding the length of the longest substring in s which is a palindrome for even count ; Finding the length of the longest substring in s which is a palindrome for one odd count ; Finding maximum length of substring having one odd count ; dp [ mask ] is minimum of current i and dp [ mask ] ; Return longest length of the substring which forms a palindrome with swaps ; Driver Code ; Input String ; Function Call
import java . io . * ; import java . util . * ; class GFG { public static int longestSubstring ( String s ) { int dp [ ] = new int [ 1024 ] ; Arrays . fill ( dp , s . length ( ) ) ; int res = 0 , mask = 0 ; dp [ 0 ] = - 1 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { mask ^= 1 << ( s . charAt ( i ) - '0' ) ; res = Math . max ( res , i - dp [ mask ] ) ; for ( int j = 0 ; j <= 9 ; ++ j ) res = Math . max ( res , i - dp [ mask ^ ( 1 << j ) ] ) ; dp [ mask ] = Math . min ( dp [ mask ] , i ) ; } return res ; } public static void main ( String [ ] args ) { String s = "3242415" ; System . out . println ( longestSubstring ( s ) ) ; } }
Convert given string to a valid mobile number | Java program for the above approach ; Function to print the valid and formatted phone number ; Length of given String ; Store digits in temp ; Iterate given M ; If any digit , append it to temp ; Find new length of String ; If length is not equal to 10 ; Store final result ; Make groups of 3 digits and enclose them within ( ) and separate them with " - " 0 to 2 index 1 st group ; 3 to 5 index 2 nd group ; 6 to 8 index 3 rd group ; 9 to 9 index last group ; Print final result ; Driver Code ; Given String ; Function Call
import java . util . * ; class GFG { static void Validate ( String M ) { int len = M . length ( ) ; String temp = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( Character . isDigit ( M . charAt ( i ) ) ) temp += M . charAt ( i ) ; } int nwlen = temp . length ( ) ; if ( nwlen != 10 ) { System . out . print ( "InvalidNEW_LINE"); return ; } String res = " " ; String x = temp . substring ( 0 , 3 ) ; res += " ( " + x + " ) - " ; x = temp . substring ( 3 , 6 ) ; res += " ( " + x + " ) - " ; x = temp . substring ( 6 , 9 ) ; res += " ( " + x + " ) - " ; x = temp . substring ( 9 , 10 ) ; res += " ( " + x + " ) " ; System . out . print ( res + "NEW_LINE"); } public static void main ( String [ ] args ) { String M = "91 ▁ 234rt5%34*0 ▁ 3" ; Validate ( M ) ; } }
Modulus of two Hexadecimal Numbers | Java program to implement the above approach ; Function to calculate modulus of two Hexadecimal numbers ; Store all possible hexadecimal digits ; Iterate over the range [ '0' , '9' ] ; Convert given string to long ; Base to get 16 power ; Store N % K ; Iterate over the digits of N ; Stores i - th digit of N ; Update ans ; Update base ; Print the answer converting into hexadecimal ; Driver Code ; Given string N and K ; Function Call
import java . util . * ; public class Main { static void hexaModK ( String N , String k ) { HashMap < Character , Integer > map = new HashMap < > ( ) ; for ( char i = '0' ; i <= '9' ; i ++ ) { map . put ( i , i - '0' ) ; } map . put ( ' A ' , 10 ) ; map . put ( ' B ' , 11 ) ; map . put ( ' C ' , 12 ) ; map . put ( ' D ' , 13 ) ; map . put ( ' E ' , 14 ) ; map . put ( ' F ' , 15 ) ; long m = Long . parseLong ( k , 16 ) ; long base = 1 ; long ans = 0 ; for ( int i = N . length ( ) - 1 ; i >= 0 ; i -- ) { long n = map . get ( N . charAt ( i ) ) % m ; ans = ( ans + ( base % m * n % m ) % m ) % m ; base = ( base % m * 16 % m ) % m ; } System . out . println ( Long . toHexString ( ans ) . toUpperCase ( ) ) ; } public static void main ( String args [ ] ) { String n = "3E8" ; String k = "13" ; hexaModK ( n , k ) ; } }
Print all combinations generated by characters of a numeric string which does not exceed N | Java program for the above approach ; Store the current sequence of s ; Store the all the required sequences ; Function to print all sequences of S satisfying the required condition ; Print all Strings in the set ; Function to generate all sequences of String S that are at most N ; Iterate over String s ; Push ith character to combination ; Convert the String to number ; Check if the condition is true ; Push the current String to the final set of sequences ; Recursively call function ; Backtrack to its previous state ; Driver Code ; Function Call ; Print required sequences
import java . util . * ; class GFG { static String combination = " " ; static HashSet < String > combinations = new LinkedHashSet < String > ( ) ; static void printSequences ( HashSet < String > combinations ) { for ( String s : combinations ) { System . out . print ( s + " ▁ " ) ; } } static void generateCombinations ( String s , int n ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { combination += ( s . charAt ( i ) ) ; long x = Integer . valueOf ( combination ) ; if ( x <= n ) { combinations . add ( combination ) ; generateCombinations ( s , n ) ; } combination = combination . substring ( 0 , combination . length ( ) - 1 ) ; } } public static void main ( String [ ] args ) { String S = "124" ; int N = 100 ; generateCombinations ( S , N ) ; printSequences ( combinations ) ; } }
Count Distinct Strings present in an array using Polynomial rolling hash function | Java program to implement the above approach ; Function to find the hash value of a string ; Traverse the string ; Update hash_val ; Update mul ; Return hash_val of str ; Function to find the count of distinct strings present in the given array ; Store the hash values of the strings ; Traverse the array ; Stores hash value of arr [ i ] ; Sort hash [ ] array ; Stores count of distinct strings in the array ; Traverse hash [ ] array ; Update cntElem ; Driver Code
import java . util . Arrays ; public class GFG { static int compute_hash ( String str ) { int p = 31 ; int MOD = ( int ) 1e9 + 7 ; int hash_val = 0 ; int mul = 1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; hash_val = ( hash_val + ( ch - ' a ' + 1 ) * mul ) % MOD ; mul = ( mul * p ) % MOD ; } return hash_val ; } static int distinct_str ( String arr [ ] , int n ) { int hash [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { hash [ i ] = compute_hash ( arr [ i ] ) ; } Arrays . sort ( hash ) ; int cntElem = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( hash [ i ] != hash [ i - 1 ] ) { cntElem ++ ; } } return cntElem ; } public static void main ( String [ ] args ) { String arr [ ] = { " abcde " , " abcce " , " abcdf " , " abcde " } ; int N = arr . length ; System . out . println ( distinct_str ( arr , N ) ) ; } }
Remove characters from given string whose frequencies are a Prime Number | Java program for the above approach ; Function to perform the seive of eratosthenes algorithm ; Initialize all entries in prime [ ] as true ; Initialize 0 and 1 as non prime ; Traversing the prime array ; If i is prime ; All multiples of i must be marked false as they are non prime ; Function to remove characters which have prime frequency in the String ; Length of the String ; Create a boolean array prime ; Sieve of Eratosthenes ; Stores the frequency of character ; Storing the frequencies ; New String that will be formed ; Removing the characters which have prime frequencies ; If the character has prime frequency then skip ; Else concatenate the character to the new String ; Print the modified String ; Driver Code ; Function Call
import java . util . * ; class GFG { static void SieveOfEratosthenes ( boolean [ ] prime , int n ) { for ( int i = 0 ; i <= n ; i ++ ) { prime [ i ] = true ; } prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( int j = 2 ; i * j <= n ; j ++ ) { prime [ i * j ] = false ; } } } } static void removePrimeFrequencies ( char [ ] s ) { int n = s . length ; boolean [ ] prime = new boolean [ n + 1 ] ; SieveOfEratosthenes ( prime , n ) ; HashMap < Character , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( m . containsKey ( s [ i ] ) ) { m . put ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; } else { m . put ( s [ i ] , 1 ) ; } } String new_String = " " ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( prime [ m . get ( s [ i ] ) ] ) continue ; new_String += s [ i ] ; } System . out . print ( new_String ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; removePrimeFrequencies ( str . toCharArray ( ) ) ; } }
Rearrange string such that no pair of adjacent characters are of the same type | Java program to implement the above approach ; Function to rearrange given alphanumeric String such that no two adjacent characters are of the same type ; Stores alphabets and digits ; Store the alphabets and digits separately in the Strings ; Stores the count of alphabets and digits ; If respective counts differ by 1 ; Desired arrangement not possible ; Stores the indexes ; Check if first character should be alphabet or digit ; Place alphabets and digits alternatively ; If current character needs to be alphabet ; If current character needs to be a digit ; Flip flag for alternate arrangement ; Return resultant String ; Driver Code ; Given String ; Function Call
class GFG { static String rearrange ( String s ) { String s1 = " " , s2 = " " , ans = " " ; char [ ] s3 = s . toCharArray ( ) ; for ( char x : s3 ) { if ( x >= ' a ' && x <= ' z ' ) s1 += x ; else s2 += x ; } int n = s1 . length ( ) ; int m = s2 . length ( ) ; if ( Math . abs ( n - m ) > 1 ) return " - 1" ; int i = 0 , j = 0 , k = 0 ; int flag = ( n >= m ) ? 1 : 0 ; while ( i < n && j < m ) { if ( flag != 0 ) ans += s1 . charAt ( i ++ ) ; else ans += s2 . charAt ( j ++ ) ; if ( flag == 1 ) flag = 0 ; else flag = 1 ; } return ans ; } public static void main ( String [ ] args ) { String str = " geeks2020" ; System . out . print ( rearrange ( str ) + "NEW_LINE"); } }
Find value after N operations to remove N characters of string S with given constraints | Java program for the above approach ; Function to find the value after N operations to remove all the N characters of String S ; Iterate till N ; Remove character at ind and decrease n ( size of String ) ; Increase count by ind + 1 ; Driver Code ; Given String str ; Function call
import java . util . * ; class GFG { static void charactersCount ( String str , int n ) { int count = 0 ; while ( n > 0 ) { char cur = str . charAt ( 0 ) ; int ind = 0 ; for ( int j = 1 ; j < n ; j ++ ) { if ( str . charAt ( j ) < cur ) { cur = str . charAt ( j ) ; ind = j ; } } str = str . substring ( 0 , ind ) + str . substring ( ind + 1 ) ; n -- ; count += ind + 1 ; } System . out . print ( count + "NEW_LINE"); } public static void main ( String [ ] args ) { String str = " aabbc " ; int n = 5 ; charactersCount ( str , n ) ; } }
Print the middle character of a string | Java program for the above approach ; Function that prints the middle character of a string ; Finding string length ; Finding middle index of string ; Print the middle character of the string ; Driver Code ; Given string str ; Function Call
class GFG { public static void printMiddleCharacter ( String str ) { int len = str . length ( ) ; int middle = len / 2 ; System . out . println ( str . charAt ( middle ) ) ; } public static void main ( String args [ ] ) { String str = " GeeksForGeeks " ; printMiddleCharacter ( str ) ; } }