FastPrepFastPrep
Problem Brief

Subarray Removal

OA

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.

1Example 1

Input
arr = [1, 2, 1, 2]
Output
7
Explanation
Example 1 illustration

Constraints

Limits and guarantees your solution can rely on.

O_O
public int subarrayRemoval(int[] arr) {
  // write your code here
}
Input

arr

[1, 2, 1, 2]

Output

7

Sign in to submit your solution.