Numbers With Same Consecutive Differences
Return allnon-negativeintegers of lengthN
such that the absolute difference between every two consecutive digits isK
.
Note thateverynumber in the answermust nothave leading zerosexceptfor the number0
itself. For example,01
has one leading zero and is invalid, but0
is valid.
You may return the answer in any order.
Example 1:
Example 2:
分析
最后一个digit, lastdigit+k<10 and lastdigit-k>=0.不是用abs这里
简化版
Last updated