Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Sorting an Array With Complexity

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Sorting an Array With Complexity. Start with the requirements on the right.

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.

Problem

The Duke Energy Outage Map may need outage-related priority values displayed in ascending order. Given an array of integers, return a new array containing the same values in nondecreasing order.

Implement the sorting algorithm yourself without calling Python's built-in sort() or sorted() functions. The input array may contain duplicate, negative, and zero values. The original input must not be modified.

Formal Specification

  • Input: nums, a list of integers.
  • Output: A new list of integers containing every value from nums, sorted in nondecreasing order.
  • Function: def sort_integers(nums):

Constraints

  • 0 <= len(nums) <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • The input list must remain unchanged

Function Signature

def sort_integers(nums):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output