Map to store the next character on the keyboard for every possible lowercase character
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 ] ; }