human
Mode in a stream of integers ( running integers ) | Function that prints the Mode values.
Map used to mp integers to its frequency.
To store the maximum frequency.
To store the element with the maximum frequency.
Loop used to read the elements one by one.
Updates the frequency of that element.
Checks for maximum Number of occurrence.
Updates the maximum frequency.
Updates the Mode.
Driver Code.
Function call"
Solution in Python:
assistant
#Here is code to mode in a stream of integers ( running integers ) and the other steps required.
 def findMode ( a , n ) :
	mp = { }
	max = 0
	mode = 0
	for i in range ( n ) :
		if a [ i ] in mp :
			mp [ a [ i ] ] += 1
		else :
			mp [ a [ i ] ] = 1
		if ( mp [ a [ i ] ] >= max ) :
			max = mp [ a [ i ] ]
			mode = a [ i ]
		print ( mode , end = " ▁ " )
arr = [ 2 , 7 , 3 , 2 , 5 ]
n = len ( arr )
findMode ( arr , n )