Google | OA | SDE (2020)| India
Anonymous User
6884

Duration: 1Hr

  1. Given array A of N Integers a1 ,a2, a3...... aN . You are also given two integers S and M. You can pick subarray of size S where you have to perform M operation by incrementing the value of each element value by 1. Find the maximum value of minimum value in array A.
    Example
Input:
N = 6 ,M = 5 ,S =2
1 2 3 4 5 6
Output:
4
Explaination:
1st opertaion subarray index range (0,1) 2 3 3 4 5 6
2nd opertaion subarray index range (0,1) 3 4 3 4 5 6
3rd opertaion subarray index range (0,1) 4 5 3 4 5 6
4th opertaion subarray index range (2,3) 4 5 4 5 5 6
5th opertaion subarray index range (0,1) 5 6 4 5 5 6
  1. You are given an array of N elements. You are allowed to delete at maximum one element from the provided array. The order of elements remains the same in the resultant array. You are required to maximize the number of subarrays that contain both maximum and minimum elements of the resultant arary.
    Constraints
    TestCases [1,10]
    N [1,105]
    1<= arri<=109
Input
6
7 2 5 4 3 1
Output
4
Explaination
If we delete 1 from the array then resultant arary will be 7 2 5 4 3. So the number of subarrays which will contain maximum 7 and minimum 2 will be 4
[7,2]
[7,2,5]
[7,2,5,4]
[7,2,5,4,3]
Comments (11)