Numbers With Same Consecutive Differences
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given integers n and k, find every n-digit non-negative integer in which the absolute difference between each pair of adjacent digits is exactly k.
Numbers must not have leading zeros (so every result has exactly n digits and is at least 10^(n-1)).
Return the numbers sorted in **ascending** order, with no duplicates.
Examples
Constraints
- `2 <= n <= 9`
- `0 <= k <= 9`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.