human
Count of integers in given range having their last K digits are equal | Function to return the count of integers from 1 to X having the last K digits as equal.
Stores the total count of integers.
Loop to iterate over all possible values of z.
Terminate the loop when z > X.
Add count of integers with last K digits equal to z.
Return count.
Function to return the count of integers from L to R having the last K digits as equal.
Driver Code.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to count of integers in given range having their last K digits are equal and the other steps required.
 def intCount ( X , K ) :
	ans = 0
	for z in range ( 0 , int ( pow ( 10 , K ) ) , int ( ( pow ( 10 , K ) - 1 ) / 9 ) ) :
		if ( z > X ) :
			break
		ans += int ( ( X - z ) / int ( pow ( 10 , K ) ) + 1 )
	return ans
def intCountInRange ( L , R , K ) :
	return ( intCount ( R , K ) - intCount ( L - 1 , K ) )
L = 49
R = 101
K = 2
print ( intCountInRange ( L , R , K ) )