FastPrepStepping Numbers Up to N
Problems/Stepping Numbers Up to N

Stepping Numbers Up to N

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 97% the same as the reported question. The Bloomberg new-grad virtual-onsite report defines the rule (neighboring digits differ by one) and later gives exact examples for n=20 and n=30. We added the upper limit, and the answer comes as a sorted array.

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)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[] steppingNumbers(int n) {
        // Write your code here.
    }

}
Checking account…