Uber | Onsite | Jumping Numbers

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2019-08-17Added By Anonymous
Source: Link

Company: Uber
Role: unknown
Interview Stage: Onsite
Location: unknown
Year: unknown

Original Post Content:

Given a positive int `n`, print all jumping numbers smaller than or equal to `n`. A number is called a jumping number if all adjacent digits in it differ by 1. For example, `8987` and `4343456` are jumping numbers, but `796` and `89098` are not. All single digit numbers are considered as jumping numbers.

Example:
Input: 105
Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98, 101]

Comments