C # implementation of the above approach
using System ; using System . Collections . Generic ; class GFG { static HashSet < String > seen = new HashSet < String > ( ) ; static List < int > edges = new List < int > ( ) ;