Class Solution
java.lang.Object
g0901_1000.s0967_numbers_with_same_consecutive_differences.Solution
967 - Numbers With Same Consecutive Differences.<p>Medium</p>
<p>Return all <strong>non-negative</strong> integers of length <code>n</code> such that the absolute difference between every two consecutive digits is <code>k</code>.</p>
<p>Note that <strong>every</strong> number in the answer <strong>must not</strong> have leading zeros. For example, <code>01</code> has one leading zero and is invalid.</p>
<p>You may return the answer in <strong>any order</strong>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 3, k = 7</p>
<p><strong>Output:</strong> [181,292,707,818,929]</p>
<p><strong>Explanation:</strong> Note that 070 is not a valid number, because it has leading zeroes.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 2, k = 1</p>
<p><strong>Output:</strong> [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 <= n <= 9</code></li>
<li><code>0 <= k <= 9</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numsSameConsecDiff
public int[] numsSameConsecDiff(int n, int k)
-