human
Find the array element having maximum frequency of the digit K | Function to find the count of digits , k in the given number n.
Stores count of occurrence of digit K in N.
Iterate over digits of N.
If current digit is k.
Update count.
Update N.
Utility function to find an array element having maximum frequency of digit k.
Stores frequency of digit K in arr [ i ].
Stores maximum frequency of digit K in the array.
Stores an array element having maximum frequency of digit k.
Traverse the array.
Count the frequency of digit k in arr [ i ].
Update max with maximum frequency found so far.
Update ele.
If there is no array element having digit k in it.
Function to find an array element having maximum frequency of digit k.
Stores an array element having maximum frequency of digit k.
If there is no element found having digit k in it.
Print element having max frequency of digit k.
Driver Code.
The digit whose max occurrence has to be found.
Given array.
Size of array.
Function Call"
Solution in Python:
 ... Write me a code to find the array element having maximum frequency of the digit K and the other steps required?
assistant
#Here is code to find the array element having maximum frequency of the digit K and the other steps required.
 def countFreq ( N , K ) :
	count = 0
	while ( N > 0 ) :
		if ( N % 10 == K ) :
			count += 1
		N = N // 10
	return count
def findElementUtil ( arr , N , K ) :
	c = 0
	max = 0
	ele = 0
	for i in range ( N ) :
		c = countFreq ( arr [ i ] , K )
		if ( c > max ) :
			max = c
			ele = arr [ i ]
	if ( max == 0 ) :
		return - 1
	else :
		return ele
def findElement ( arr , N , K ) :
	ele = findElementUtil ( arr , N , K )
	if ( ele == - 1 ) :
		print ( " - 1" , end = " " )
	else :
		print ( ele )
if __name__ == ' _ _ main _ _ ' :
	K = 3
	arr = [ 3 , 77 , 343 , 456 ]
	N = len ( arr )
	findElement ( arr , K , N )