text: Find the player who is the last to remove any character from the beginning of a Binary String | C # program for the above approach ; Function to find the player who loses the game ; Moves for the first player ; Moves for the second player ; Iterate over array of strings ; Check if the first and last character are the same ; Check if string start and end with character '0' ; If first player have less moves ; Driver Code ; Given array of strings ; Function call
code: using System ; class GFG { static void findPlayer ( string [ ] str , int n ) { int move_first = 0 ; int move_sec = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] [ 0 ] == str [ i ] [ str [ i ] . Length - 1 ] ) { if ( ( str [ i ] [ 0 ] ) == 48 ) move_first ++ ; else move_sec ++ ; } } if ( move_first <= move_sec ) { Console . Write ( " Player ▁ 2 ▁ wins " ) ; } else { Console . Write ( " Player ▁ 1 ▁ wins " ) ; } } public static void Main ( ) { string [ ] str = { "010" , "101" } ; int N = str . Length ; findPlayer ( str , N ) ; } }