Stepping Numbers Up to N
Updated
Problem statement
A positive integer is a stepping number when the absolute difference between every pair of adjacent decimal digits is exactly 1. Every one-digit positive integer is a stepping number.
Given n, return all stepping numbers in the inclusive range [1, n] in increasing order.
Function
steppingNumbers(n: int) → int[]Examples
Example 1
n = 20return = [1,2,3,4,5,6,7,8,9,10,12]All one-digit values qualify. Among two-digit values at most twenty, only 10 and 12 have adjacent digits differing by one.
Example 2
n = 30return = [1,2,3,4,5,6,7,8,9,10,12,21,23]Compared with the first example, 21 and 23 also qualify.
Example 3
n = 9return = [1,2,3,4,5,6,7,8,9]Every positive one-digit number is a stepping number.
Constraints
1 <= n <= 1000000000.
More Bloomberg LP Onsite Interview questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Minimum Moves for Two Knights to MeetAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Smallest Binary-Digit MultipleMyntra · ONSITE INTERVIEWMyntra interview questions
- Unit Conversion Across Independent FamiliesApple · PHONE SCREENApple interview questions
- Count Reachable Values by Halving and DecrementingInfosys · OAInfosys interview questions
- Frog Position After T SecondsInMobi · PHONE SCREENInMobi interview questions
- Count Level-Order Traversals of a TreeBank of America · OABank of America interview questions
- Reaching Points with Perfect-Square ObstaclesIMC Trading · OAIMC Trading interview questions
- Broken CalculatorNutanix · OANutanix interview questions
- Count Pasture Animal ArrangementsIntuit · OAIntuit interview questions
- Tree Path GCDNewton School · PHONE SCREEN
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)