text: Print all strings from given array that can be typed using keys from a single row of a QWERTY keyboard | C # program to implement the above approach ; Function to print all strings that can be typed using keys of a single row in a QWERTY Keyboard ; Stores row number of all possible character of the strings ; Traverse the array ; If current string is not an empty string ; Sets true / false if a string can be typed using keys of a single row or not ; Stores row number of the first character of current string ; Stores length of word ; Traverse current string ; If current character can 't be  typed using keys of rowNum only ; Update flag ; If current string can be typed using keys from rowNum only ; Print the string ; Driver Code
code: using System ; using System . Collections . Generic ; class GFG { static void findWordsSameRow ( List < string > arr ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; mp . Add ( ' q ' , 1 ) ; mp . Add ( ' w ' , 1 ) ; mp . Add ( ' e ' , 1 ) ; mp . Add ( ' r ' , 1 ) ; mp . Add ( ' t ' , 1 ) ; mp . Add ( ' y ' , 1 ) ; mp . Add ( ' u ' , 1 ) ; mp . Add ( ' i ' , 1 ) ; mp . Add ( ' o ' , 1 ) ; mp . Add ( ' p ' , 1 ) ; mp . Add ( ' a ' , 2 ) ; mp . Add ( ' s ' , 2 ) ; mp . Add ( ' d ' , 2 ) ; mp . Add ( ' f ' , 2 ) ; mp . Add ( ' g ' , 2 ) ; mp . Add ( ' h ' , 2 ) ; mp . Add ( ' j ' , 2 ) ; mp . Add ( ' k ' , 2 ) ; mp . Add ( ' l ' , 2 ) ; mp . Add ( ' z ' , 3 ) ; mp . Add ( ' x ' , 3 ) ; mp . Add ( ' c ' , 3 ) ; mp . Add ( ' v ' , 3 ) ; mp . Add ( ' b ' , 3 ) ; mp . Add ( ' n ' , 3 ) ; mp . Add ( ' m ' , 3 ) ; foreach ( string word in arr ) { if ( word . Length != 0 ) { bool flag = true ; int rowNum = mp [ char . ToLower ( word [ 0 ] ) ] ; int M = word . Length ; for ( int i = 1 ; i < M ; i ++ ) { if ( mp [ Char . ToLower ( word [ i ] ) ] != rowNum ) { flag = false ; break ; } } if ( flag ) { Console . Write ( word + " ▁ " ) ; } } } } public static void Main ( String [ ] args ) { List < string > words = new List < string > ( new string [ ] { " Yeti " , " Had " , " GFG " , " comment " } ) ; findWordsSameRow ( words ) ; } }