Optimal Strategy for a Game | Special Gold Coin | C # implementation of the approach ; Function to return the winner of the game ; To store the count of silver coins ; Update the position of the gold coin ; First player will win the game ; Driver code
using System ; class GFG { static String getWinner ( String str , int len ) { int total = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' S ' ) { total ++ ; } } if ( ( total % 2 ) == 1 ) return " First " ; return " Second " ; } public static void Main ( string [ ] args ) { string str = " GSSS " ; int len = str . Length ; Console . WriteLine ( getWinner ( str , len ) ) ; } }