Driver code
public static void Main ( String [ ] args ) { int n = 10 ; List < int > [ ] g = new List < int > [ n + 1 ] ; for ( int i = 0 ; i < g . Length ; i ++ ) g [ i ] = new List < int > ( ) ; g [ 1 ] . Add ( 2 ) ; g [ 2 ] . Add ( 1 ) ; g [ 1 ] . Add ( 3 ) ; g [ 3 ] . Add ( 1 ) ; g [ 1 ] . Add ( 4 ) ; g [ 4 ] . Add ( 1 ) ; g [ 2 ] . Add ( 5 ) ; g [ 5 ] . Add ( 2 ) ; g [ 2 ] . Add ( 6 ) ; g [ 6 ] . Add ( 2 ) ; g [ 3 ] . Add ( 7 ) ; g [ 7 ] . Add ( 3 ) ; g [ 4 ] . Add ( 10 ) ; g [ 10 ] . Add ( 4 ) ; g [ 8 ] . Add ( 7 ) ; g [ 7 ] . Add ( 8 ) ; g [ 9 ] . Add ( 7 ) ; g [ 7 ] . Add ( 9 ) ; List < int > v = new List < int > ( ) ; v . Add ( 7 ) ; v . Add ( 3 ) ; v . Add ( 8 ) ; Console . Write ( findLCA ( n , g , v ) + " STRNEWLINE " ) ; } }