FastPrepImplement Quicksort
Problems/Implement Quicksort

Implement Quicksort

JP Morgan Chase logoJP Morgan Chase● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern onsite interview. One software engineering interviewer asks for quicksort after rejecting STL sort. A separate candidate in the investment bank picks quicksort when asked to sort, and is asked to sort again in another round. The algorithm for that second round is not reported. This exercise uses quicksort for all three cases. We chose the interface, the limits and the examples. Our version is about 85% the same as the reported tasks.

Sort nums in increasing numeric order using your own quicksort implementation, and return the sorted array. Preserve every occurrence of a repeated value.

Partition the array and process the remaining partitions. Do not call a library sorting function. You may mutate the input array, and may use an explicit stack to avoid recursive call-depth limits.

The returned values are checked by the runner; the quicksort and no-library-sort requirements are part of the exercise and solution review.

Function

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

Examples

Example 1

nums = [3,1,2,1]return = [1,1,2,3]

Increasing order is 1,1,2,3, with both occurrences of 1 retained.

Example 2

nums = []return = []

An empty array is already sorted.

Constraints

  • 0 <= nums.length <= 3000
  • -10^6 <= nums[i] <= 10^6

More JP Morgan Chase Onsite Interview questions

  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU CacheONSITE INTERVIEW · Seen Nov 2026
  • Employees Above Average SalaryONSITE INTERVIEW · Seen Sep 2026
  • Highest-Earning Employees By DepartmentONSITE INTERVIEW · Seen Sep 2026
  • K Largest Integers in Descending OrderONSITE INTERVIEW · Seen Aug 2026
  • Tile a Three-Row Board with DominoesONSITE INTERVIEW · Seen Jan 2026
  • Two SumONSITE INTERVIEW · Seen Nov 2025
  • Intersection of Two ListsONSITE INTERVIEW · Seen Jan 2025
  • Maximum Subarray SumONSITE INTERVIEW · Seen Jan 2025
  • Fibonacci NumberONSITE INTERVIEW · Seen Nov 2024

Similar questions at other companies

  • Predict AnswerAmazon · OA
  • Most Segments That Sort the ArrayRippling · OARippling interview questions
  • Alternating Jumps to the Last IndexExpedia · OAExpedia interview questions
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • 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

Interview reports that mention this question

  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JPMorgan Chase Intern Campus Rounds: 4 Experiences (Part 2 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int[] quickSort(int[] nums) {
        // Write your code here.
    }
}
Checking account…