Skip to content

Latest commit

 

History

History
17 lines (9 loc) · 547 Bytes

Subarray_Sort.md

File metadata and controls

17 lines (9 loc) · 547 Bytes

Subarray Sort

Problem Statement

Write a function that takes in an array of integers of length at least 2. The function should return an array of the starting and ending indices of the smallest subarray in the input array that needs to be sorted in place in order for the entire input array to be sorted. If the input array is already sorted, the function should return [-1, -1].

Sample input: [1, 2, 4, 7, 10, 11, 7, 12, 6, 7, 16, 18, 19] Sample output: [3, 9]

Solution

Check this Python code.