# 967. Numbers With Same Consecutive Differences

#### Medium

***

Return all **non-negative** integers of length `n` such that the absolute difference between every two consecutive digits is `k`.

Note that **every** number in the answer **must not** have leading zeros. For example, `01` has one leading zero and is invalid.

You may return the answer in **any order**.

&#x20;

**Example 1:**

<pre><code>Input: n = 3, k = 7
<strong>Output:
</strong> [181,292,707,818,929]
<strong>Explanation:
</strong> Note that 070 is not a valid number, because it has leading zeroes.
</code></pre>

**Example 2:**

<pre><code>Input: n = 2, k = 1
<strong>Output:
</strong> [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]
</code></pre>

&#x20;

**Constraints:**

* `2 <= n <= 9`
* `0 <= k <= 9`

```python
class Solution:
    def numsSameConsecDiff(self, N, K):
        #.
        cur = range(1, 10)
        for i in range(N - 1):
            cur = {x * 10 + y for x in cur for y in [x % 10 + K, x % 10 - K] if 0 <= y <= 9}
        return list(cur)
        
```
