FastPrepConsecutive Number Ranges
Problems/Consecutive Number Ranges

Consecutive Number Ranges

Microsoft logoMicrosoft● MediumNEW GRADPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Applied Data and Science PhD internship phone screen asks the candidate to output consecutive numbers in an array. Distinct-value maximal ranges, sorting, singleton representation, interface, and bounds are conventional enrichment selected from the thin source.

Given an integer array nums, return the maximal ranges of consecutive integer values present in the array.

Ignore duplicate values. Represent each range as [start,end], including singleton ranges where start = end. Return ranges in increasing order by start.

Function

consecutiveRanges(nums: int[]) → int[][]

Examples

Example 1

nums = [100,4,200,1,3,2,2]return = [[1,4],[100,100],[200,200]]

The distinct values 1,2,3,4 form one maximal range; 100 and 200 are singleton ranges.

Example 2

nums = []return = []

An empty array contains no consecutive-value ranges.

Constraints

  • 0 <= nums.length <= 100000
  • -10^9 <= nums[i] <= 10^9

More Microsoft Phone Screen questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Corporation Reporting LinesPHONE SCREEN · Seen Oct 2026
  • Random Forest Classifier from ScratchPHONE SCREEN · Seen Oct 2026
  • Least Recently Used CacheOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Greedy and Beam Sentence DecodingPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Sep 2026
  • 3SumPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Arithmetic Expression EvaluatorPHONE SCREEN · Seen Sep 2026
  • Employee Hierarchy Cycle and Depth AnalysisPHONE SCREEN · Seen Sep 2026
  • Most Visited String SectorsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Top Ten Largest FilesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Valid Triangle NumberBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Implement QuicksortByteDance · PHONE SCREENByteDance interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEWDuolingo interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Fair Capped Money DistributionGusto · PHONE SCREEN · ONSITE INTERVIEWGusto interview questions
  • Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int[][] consecutiveRanges(int[] nums) {
      // Write your code here.
    }

}
Checking account…