FastPrepQuick Sort
Problems/Quick Sort

Quick Sort

Microsoft logoMicrosoft● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The round is not named in the review. It describes an on-campus Microsoft software engineering internship process with a coding round followed by a pair of technical interviews. The review lists quicksort by name only, with no input or rules, next to a math riddle.

Here you sort an integer array of 1 to 5000 values between -10^5 and 10^5 into increasing order and return it. The statement asks you to write quicksort yourself, which the judge cannot check.

Our version is about 90% the same as the reported question.

Given an integer array nums, sort it in increasing order using quicksort and return the sorted array. Keep repeated values.

Write the sort yourself instead of calling a built-in sort. The judge checks only the returned array, so this rule is not checked automatically.

Function

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

Examples

Example 1

nums = [5,2,9,1,5,6]return = [1,2,5,5,6,9]

In increasing order the values are 1, 2, 5, 5, 6, 9. Both 5s are kept.

Example 2

nums = [3,-1,0]return = [-1,0,3]

Negative values come first: [-1, 0, 3].

Example 3

nums = [7]return = [7]

A single element is already sorted.

Constraints

  • 1 <= nums.length <= 5000
  • -10^5 <= nums[i] <= 10^5

More Microsoft Onsite Interview questions

  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026
  • Totals from a Tiered Rate TableONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
  • Merge Intervals from Start and End ListsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Keyboard Autocomplete SuggestionsLyft · ONSITE INTERVIEWLyft interview questions
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
  • Maximum Intervals Overlapping a Fixed-Length WindowBooking.com · ONSITE INTERVIEW

Interview reports that mention this question

  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • 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, Late 2025: 47 Experiences (Part 3 of 6)
  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int[] sortArray(int[] nums) {
        // Write your code here.
    }
}
Checking account…