You are given three integers l, r and k.
A number is considered good if the absolute difference between every pair of adjacent digits is at most k.
Return the number of good integers in the range [l, r] (inclusive).
The absolute difference between values x and y is defined as abs(x - y).
Example 1:
Input: l = 10, r = 15, k = 1
Output: 3
Explanation:
abs(1 - 0) = 1.abs(1 - 1) = 0.abs(1 - 2) = 1.k = 1. Thus, the answer is 3.Example 2:
Input: l = 201, r = 204, k = 2
Output: 2
Explanation:
abs(2 - 0) = 2 and abs(0 - 1) = 1.abs(2 - 0) = 2 and abs(0 - 2) = 2.Constraints:
10 <= l <= r <= 10150 <= k <= 9Loading editor...
10 15 1