Mode of frequencies of given array elements | Python3 program of the above approach ; Function to find the mode of the frequency of the array ; Stores the frequencies of array elements ; Traverse through array elements and count frequencies ; Stores the frequencies 's of  frequencies of array elements ; Stores the minimum value ; Find the Mode in 2 nd map ; search for this Mode ; When mode is find then return to main function . ; If mode is not found ; Driver Code
from collections import defaultdict NEW_LINE import sys NEW_LINE def countFreq ( arr , n ) : NEW_LINE INDENT mp1 = defaultdict ( int ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT mp1 [ arr [ i ] ] += 1 NEW_LINE mp2 = defaultdict ( int ) NEW_LINE for it in mp1 : NEW_LINE mp2 [ mp1 [ it ] ] += 1 NEW_LINE M = - sys . maxsize - 1 NEW_LINE for it in mp2 : NEW_LINE INDENT M = max ( M , mp2 [ it ] ) NEW_LINE for it in mp2 : NEW_LINE if ( M == mp2 [ it ] ) : NEW_LINE INDENT return it NEW_LINE DEDENT return 0 NEW_LINE DEDENT DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 6 , 10 , 3 , 10 , 8 , 3 , 6 , 4 ] NEW_LINE n = len ( arr ) NEW_LINE print ( countFreq ( arr , n ) ) NEW_LINE DEDENT