Store frequencies of elements in a hash table .
Dictionary < int , int > hash = new Dictionary < int , int > ( ) ; Node temp = head ; while ( temp != null ) { if ( hash . ContainsKey ( temp . data ) ) hash [ temp . data ] = hash [ temp . data ] + 1 ; else hash . Add ( temp . data , 1 ) ; temp = temp . next ; } temp = head ;