2
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:3
# initialize the cache with all the valid numbers of length 14
# cache is a list of tuple (number, digit at units place)19
# each iteration will store all the valid numbers of length 2 to n in cache20
for i in range(2, n + 1):21
# loop through the cache from the previous iteration25
cacheTemp.append((j[0] * 10 + j[1], j[1]))26
elif j[1] == 0 and i == 2:30
cacheTemp.append((j[0] * 10 + j[1] + k, j[1] + k))33
cacheTemp.append((j[0] * 10 + j[1] - k, j[1] - k))35
cacheTemp.append((j[0] * 10 + j[1] - k, j[1] - k))36
cacheTemp.append((j[0] * 10 + j[1] + k, j[1] + k))37
cache = cacheTemp # store the list of valid integers of length i in cache38
cacheTemp = [] # empty the temporary list