Company: DeShaw_24july
Difficulty: medium
Minimum Indices to Cover Positions Problem Description You are given an array arr of length n . You can choose a set of indices and for each chosen index i , you can perform one of the following operations: Cover positions from max(i - arr[i] + 1, 0) to i . Cover positions from i to min(i + arr[i] - 1, n - 1) . Your task is to find the minimum number of indices to choose so that all positions from 0 to n - 1 are covered. Complete the function getMinIndices in the editor below. getMinIndices has the following parameter: int arr[] : the elements of arr . Returns int : the minimum number of indices needed. The function signature is: int getMinIndices(vector arr) Examples Example 1: Input: n = 2, arr = [2, 1] Output: 1 Explanation: If we choose index 0 and use it to the right, it covers positions 0 to min(0 + 2 - 1, 2 - 1) = min(1, 1) = 1 . This covers both positions 0 and 1. Hence, the answer is 1. Example 2: Input: n = 4, arr = [1, 2, 1, 1] Output: 3 Explanation: One way to cover all pos