<p>Given two integers n and k, return <em>an array of all the integers of length </em><code>n</code><em> where the difference between every two consecutive digits is </em><code>k</code>. You may return the answer in <strong>any order</strong>.</p>

<p>Note that the integers should not have leading zeros. Integers as <code>02</code> and <code>043</code> are not allowed.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> 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.
</pre>

<p><strong class="example">Example 2:</strong></p>

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

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= n &lt;= 9</code></li>
	<li><code>0 &lt;= k &lt;= 9</code></li>
</ul>

class Solution {
public:
    void dfs(int idx, vector<int> &path, vector<vector<int>> &ans, int n, int k){
        if(idx == n){
            //cout<<"In solution";
            ans.push_back(path);
            return;
        }

        for(int i = 0; i <= 9; i++){
            //cout<<"In for";
            if(idx == 0 && i == 0)
                continue;
            if(idx == 0){
                //cout<<"In idx == 0 for";
                path.push_back(i);
                dfs(idx+1, path, ans, n, k);
                path.pop_back();
            } else {
                int last_digit = path.back();
                if(abs(last_digit - i) == k){
                    path.push_back(i);
                    dfs(idx+1, path, ans, n, k);
                    path.pop_back();
                }
            }
        }
    }
    vector<int> numsSameConsecDiff(int n, int k) {
        vector<int> path;
        vector<vector<int>> ans;
        cout<<"HELLLOO";
        dfs(0, path, ans, n, k);
        vector<int> sol;
        int digital = 0;
        for(auto digits : ans){ 
            for(auto digit: digits){
                cout<<digit<<"Y";
                digital = digital*10 + digit;
            }
            sol.push_back(digital);
            digital = 0;
            cout<<"\n";
        }
        return sol;
    }
};
11100