Question: DE SHAW OA 2023 | Subarray Removal
0
Entering edit mode

 

 

Subarray Removal
Given an array arr of n integers, find the number of its subarrays such that removing the subarray
creates a non-empty array that is sorted in increasing order.
Note: A subarray is defined as any contiguous segment of the array.
Example
suppose n = 4 and arr = [1, 2, 1, 2]

 
SubarrayArray after removing subarrayis Empty and sorted
[1][2,1,2]No
[1,2][1,2]Yes
[1,2,1][2]Yes
[1,2,1,2][]No
[2][1,1,2]Yes
[2,1][1,2]Yes
[2,1,2][1]Yes
[1][1,2,2]Yes
[1,2][1,2]Yes

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ADD COMMENTlink 19 months ago manohar • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts