Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Array Sorting With Memory
00:00
5 left

Array Sorting With Memory

MediumPython

Problem

Explain how you would sort an array and what memory allocation considerations you would take into account.

Implement an in-place ascending sort that returns the same list object after modification. Prefer an approach with predictable O(n log n) time and O(1) auxiliary space; explain how your choice compares with allocation-heavy alternatives.

Function: def sort_array(nums):. Input and output are lists of integers.

Constraints

  • 0 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9
  • The input list must be modified in place
  • Return the same list object after sorting

Function Signature

def sort_array(nums):
Interviewer

Your question is Array Sorting With Memory. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.