Company: Mathworks_31july
Difficulty: medium
Slow and Fast Pointers Problem Description Process an array using two pointers to determine the minimum valid segment size. Given an array arr , process it using pointers P1 and P2 and a segment size segSize as follows: Start with P1 = 0 and P2 = 1 . Compare arr[P1] with all elements in a subarray starting at arr[P2] and including segSize elements (or until the end of arr ). If arr[P1] is greater than or equal to all elements in the subarray, increment P1 by 1 and P2 by segSize . Repeat until the entire array has been processed. Determine the minimum value of segSize that allows the entire array to be processed successfully, or return -1 if not possible. Complete the function dualSpeed in the editor with the following parameter: int arr[n] : an array of integers Constraints The function is expected to return an INTEGER : the minimum segSize to allow all elements to be processed, or -1 if it is impossible. 1 1 9 Input Format For Custom Testing The first line contains an integer, n , the