human
Number of common digits present in two given numbers | Function to count number of digits that are common in both N and M.
Stores the count of common digits.
Stores the count of digits of N.
Stores the count of digits of M.
Iterate over the digits of N.
Increment the count of last digit of N.
Update N.
Iterate over the digits of M.
Increment the count of last digit of M.
Update M.
Iterate over the range [ 0 , 9 ].
If freq1 [ i ] and freq2 [ i ] both exceeds 0.
Increment count by 1.
Return the count.
Driver Code.
Input"
Solution in Python:
assistant
#Here is code to number of common digits present in two given numbers and the other steps required.
 def CommonDigits ( N , M ) :
	count = 0
	freq1 = [ 0 ] * 10
	freq2 = [ 0 ] * 10
	while ( N > 0 ) :
		freq1 [ N % 10 ] += 1
		N = N // 10
	while ( M > 0 ) :
		freq2 [ M % 10 ] += 1
		M = M // 10
	for i in range ( 10 ) :
		if ( freq1 [ i ] > 0 and freq2 [ i ] > 0 ) :
			count += 1
	return count
if __name__ == ' _ _ main _ _ ' :
	N = 748294
	M = 34298156
	print ( CommonDigits ( N , M ) )