SPRINKLR Hiring | OA (2021) | Identifying the Smallest Continuous Segment Required to Sort an Entire Array
Sprinklr · Question · Posted Jun 2026
Problem Statement Given an integer array nums, find the length of the shortest continuous subarray such that if only this subarray is sorted in ascending order, the entire array becomes sorted. Return the length of this subarray. If the array is already sorted, return 0. Example 1 Input: nums = [2,6,4,8,10,9,15] Output: 5 Explanation Sorting the subarray: [6,4,8,10,9] results in: [2,4,6,8,9,10,15] which makes the entire array sorted. Length: 5 Example 2 Input: nums = [1,2,3,4] Output: 0 Explanation The array ...
The full answer & interview discussion are available to premium members.
Log in Create a free account