FastPrepSort an Array
Problems/Sort an Array

Sort an Array

Bank of America logoBank of America● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by a new grad software engineer from a Bank of America campus hiring drive. In the third and last round, an interview with both technical and HR questions, the candidate was asked about merge sort and quick sort.

The report names only the two algorithms. Here, you sort an array of up to 2,000 integers, which may repeat, into non-decreasing order with a sort you write yourself, and the editorial covers both merge sort and quick sort.

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

Given an integer array nums, sort it in non-decreasing order and return the sorted array.

Write the sort yourself, for example merge sort or quick sort, instead of calling a built-in sort function.

Function

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

Examples

Example 1

nums = [14,-6,0,9,-6,3]return = [-6,-6,0,3,9,14]

The smallest value is -6, which appears twice, so both copies come first. The other values follow from smallest to largest: 0, 3, 9, 14.

Example 2

nums = [100,-100]return = [-100,100]

The two values are out of order, so they trade places.

Example 3

nums = [2,4,4,10]return = [2,4,4,10]

The array is already in non-decreasing order, so it comes back unchanged.

Constraints

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

More Bank of America Onsite Interview questions

  • Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
  • Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
  • N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
  • Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
  • Second Highest SalaryONSITE INTERVIEW · Seen Nov 2025
  • Three Numbers That Add Up to a TargetONSITE INTERVIEW · Seen Apr 2025
  • Duplicate RowsONSITE INTERVIEW · Seen Oct 2023
  • Factorial of a NumberONSITE INTERVIEW · Seen Oct 2023
  • Palindrome String CheckONSITE INTERVIEW · Seen Sep 2023

Similar questions at other companies

  • Merge Sort Report with a Noisy ComparatorMercor · ONSITE INTERVIEWMercor interview questions
  • K Largest Elements with QuickselectAMD · ONSITE INTERVIEWAMD interview questions
  • Implement Merge SortSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Generalized N-SumBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Count InversionsExpedia · OAExpedia interview questions
  • Count InversionsNutanix · OANutanix interview questions
  • Closest Pair of PointsCitadel · PHONE SCREENCitadel interview questions
  • Temporal AnomaliesInMobi · OAInMobi interview questions
  • Minimum Euclidean Distance Between PointsLuma AI · OALuma AI interview questions
  • Count Inversions With Merge SortAdobe · PHONE SCREENAdobe interview questions

Bank of America interview experiences

  • Bank of America interviews · December 2025
  • Bank of America OA · December 2025
  • Bank of America interviews · September 2026
  • Bank of America OA · September 2026
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public int[] sortArray(int[] nums) {
        // write your code here
    }
}
Checking account…