P15288 [GeeksforGeeks] Count numbers with unit digit k in given range4025
普及-
题目描述

Given a range from low to high and a number K. The task is to count the number which has the unit digit equal to K.

Example 1:
Input:
low = 4, high = 9, K = 4
Output:
1
Explanation:
4 is the only number with 4 as the
unit digit in the range of (4,9).
Example 2:
Input:
low = 3, high = 35, K = 3
Output:
4
Explanation:
3, 13, 23, and 33 are the only numbers
with 3 as the unit digit in the given range.

Your Task:
You don't need to read input or print anything. Your task is to complete the function countLastDigitK() which takes 3 Integers low, high, and K as input and returns the answer.

Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Constraints:
1 <= low <= high <= 10^{9}
0 <= K <= 9

输入格式

见题面

输出格式

见题面

样例输入
low = 4, high = 9, K = 4
样例输出
1