Find out the correct position of the ball after shuffling | C # implementation of the above approach ; Function to generate the index of the glass containing the ball ; Change the index ; Change the index ; Print the index ; Driver Code ; Storing all the shuffle operation
using System ; class GFG { static int M = 3 ; static int N = 2 ; static void getIndex ( int n , int [ , ] shuffle ) { for ( int i = 0 ; i < 3 ; i ++ ) { if ( shuffle [ i , 0 ] == n ) n = shuffle [ i , 1 ] ; else if ( shuffle [ i , 1 ] == n ) n = shuffle [ i , 0 ] ; } Console . WriteLine ( n ) ; } public static void Main ( String [ ] args ) { int n = 3 ; int [ , ] shuffle = { { 3 , 1 } , { 2 , 1 } , { 1 , 2 } } ; getIndex ( n , shuffle ) ; } }