Company: Uidai_2_Jan
Difficulty: medium
K-special numbers K-special numbers Statement You are given a range [L, R] and an integer k . Take an integer A written in decimal with n digits a 1 a 2 ...a n and no leading zeros. Call A a K-special number whenever, at every digit position i from 1 to n , this relation holds: (a i mod k) ≡ (i mod k) Task Count how many K-special numbers fall within the inclusive range [L, R] . Notes The problem uses 1-based indexing for digit positions. For example, in the number 123, a 1 =1 , a 2 =2 , and a 3 =3 . Example 1 Input: k = 2, L = 8, R = 15 Output: 4 Explanation: The numbers in the range [8, 15] are {8, 9, 10, 11, 12, 13, 14, 15}. The K-special numbers are {9, 10, 12, 14}. For example, let's check the number 14: - For the 1st digit (a 1 =1): (1 mod 2) ≡ (1 mod 2) → 1 ≡ 1. (True) - For the 2nd digit (a 2 =4): (4 mod 2) ≡ (2 mod 2) → 0 ≡ 0. (True) Since the condition holds for all digits, 14 is a K-special number. The total count of such numbers in th