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 : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . data = ' ' NEW_LINE self . next = None NEW_LINE DEDENT DEDENT def maxChar ( head ) : NEW_LINE INDENT p = head NEW_LINE hash = [ 0 for i in range ( 256 ) ] NEW_LINE while ( p != None ) : NEW_LINE hash [ ord ( p . data ) ] += 1 NEW_LINE p = p . next NEW_LINE p = head NEW_LINE max = - 1 NEW_LINE res = ' ' NEW_LINE while ( p != None ) : NEW_LINE if ( max < hash [ ord ( p . data ) ] ) : NEW_LINE INDENT res = p . data NEW_LINE max = hash [ ord ( p . data ) ] NEW_LINE DEDENT p = p . next NEW_LINE return res NEW_LINE DEDENT def push ( head_ref , new_data ) : NEW_LINE INDENT new_node = Node ( ) NEW_LINE new_node . data = new_data NEW_LINE new_node . next = ( head_ref ) NEW_LINE ( head_ref ) = new_node NEW_LINE return head_ref NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT head = None NEW_LINE str = " skeegforskeeg " NEW_LINE for i in range ( len ( str ) ) : NEW_LINE INDENT head = push ( head , str [ i ] ) NEW_LINE DEDENT print ( maxChar ( head ) ) NEW_LINE DEDENT