Modify the string such that every character gets replaced with the next character in the keyboard | C # implementation of the approach ; Function to return the modified String ; Map to store the next character on the keyboard for every possible lowercase character ; Update the String ; Driver code
using System ; using System . Collections . Generic ; class GFG { static String CHARS = " qwertyuiopasdfghjklzxcvbnm " ; static int MAX = 26 ; static String getString ( char [ ] str , int n ) { Dictionary < char , char > uMap = new Dictionary < char , char > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( ! uMap . ContainsKey ( CHARS [ i ] ) ) uMap . Add ( CHARS [ i ] , CHARS [ ( i + 1 ) % MAX ] ) ; else uMap [ CHARS [ i ] ] = CHARS [ ( i + 1 ) % MAX ] ; } for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = uMap [ str [ i ] ] ; } return String . Join ( " " , str ) ; } public static void Main ( String [ ] args ) { String str = " geeks " ; int n = str . Length ; Console . WriteLine ( getString ( str . ToCharArray ( ) , n ) ) ; } }