Maximum occurring character in a linked list | C # program to count the maximum occurring character in linked list ; Link list node ; Storing element 's frequencies  in a hash table. ; calculating the first maximum element ; Push a node to linked list . Note that this function changes the head ; Driver Code
using System ; public class GFG { class Node { public char data ; public Node next ; } ; static Node head ; static char maxChar ( Node head ) { Node p = head ; int [ ] hash = new int [ 256 ] ; while ( p != null ) { hash [ p . data ] ++ ; p = p . next ; } p = head ; int max = - 1 ; char res = ' \x0000' ; while ( p != null ) { if ( max < hash [ p . data ] ) { res = p . data ; max = hash [ p . data ] ; } p = p . next ; } return res ; } static void push ( Node head_ref , char new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; head = head_ref ; } public static void Main ( String [ ] args ) { head = null ; char [ ] str = " skeegforskeeg " . ToCharArray ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { push ( head , str [ i ] ) ; } Console . WriteLine ( maxChar ( head ) ) ; } }