Problem · Array

Subarray Removal

Learn this problem
MediumThe D. E. Shaw Group logoThe D. E. Shaw GroupOA

Problem statement

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.

Function

subarrayRemoval(arr: int[]) → int

Examples

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
checking account