Problem · Array

Subarray Removal

MediumThe D. E. Shaw GroupOA

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.

Examples
01 · Example 1
arr = [1, 2, 1, 2]
return = 7
Example 1 illustration
Constraints
O_O
More The D. E. Shaw Group problems
drafts saved locally
public int subarrayRemoval(int[] arr) {
  // write your code here
}
arr[1, 2, 1, 2]
expected7
sign in to submit