Maximum occurring character in a 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
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } var head = null ; function maxChar ( head ) { var p = head ; var hash = new Array ( 256 ) . fill ( 0 ) ; while ( p != null ) { hash [ p . data . charCodeAt ( 0 ) ] ++ ; p = p . next ; } p = head ; var max = - 1 ; var res = " " ; while ( p != null ) { if ( max < hash [ p . data . charCodeAt ( 0 ) ] ) { res = p . data ; max = hash [ p . data . charCodeAt ( 0 ) ] ; } p = p . next ; } return res ; } function push ( head_ref , new_data ) { var new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; head = head_ref ; } head = null ; var str = " " . split ( " " ) ; for ( var i = 0 ; i < str . length ; i ++ ) { push ( head , str [ i ] ) ; } document . write ( maxChar ( head ) + " " ) ;