Find first non | C # implementation to find the first non - repeating element of the string using Linked List ; Function to find the first non - repeating element of the given string using Linked List ; Driver Code ; Function call
using System ; using System . Collections ; using System . Collections . Generic ; class FirstNonRepeatingElement { static void firstNonRepElement ( string str ) { LinkedList < char > list = new LinkedList < char > ( ) ; list . AddLast ( str [ 0 ] ) ; for ( int i = 1 ; i < str . Length ; i ++ ) { if ( list . Contains ( str [ i ] ) ) list . Remove ( str [ i ] ) ; else list . AddLast ( str [ i ] ) ; } Console . Write ( list . First . Value ) ; } public static void Main ( string [ ] args ) { string str = " geeksforgeeks " ; firstNonRepElement ( str ) ; } }