967. Numbers With Same Consecutive Differences Medium
1/**
2 * [967] Numbers With Same Consecutive Differences
3 *
4 * Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
5 * Note that every number in the answer must not have leading zeros. For example, 01 has one leading zero and is invalid.
6 * You may return the answer in any order.
7 *
8 * Example 1:
9 *
10 * Input: n = 3, k = 7
11 * Output: [181,292,707,818,929]
12 * Explanation: Note that 070 is not a valid number, because it has leading zeroes.
13 *
14 * Example 2:
15 *
16 * Input: n = 2, k = 1
17 * Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]
18 *
19 *
20 * Constraints:
21 *
22 * 2 <= n <= 9
23 * 0 <= k <= 9
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/numbers-with-same-consecutive-differences/
29// discuss: https://leetcode.com/problems/numbers-with-same-consecutive-differences/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn nums_same_consec_diff(n: i32, k: i32) -> Vec<i32> {
35 vec![]
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_967() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.