QUESTION 1:
You are given an array A of N integers and a value K. Also, there are two types of values - value of an array and value of a subarray.
The values are defined as follows:
Determine the maximum value of the array.
EXAMPLE:
Input
k = 3
N = 5
A = [2,1,2,3,3]
Output
11
Approach
CONSTRAINTS:
1<=N<=10^5
1<=K<=N
1<=A[i]<=10^6
MOD = 10^9+7
QUESTION 2:
Given an array A of size N and an integer K. You can start from any index of the array and move either in the right direction or in the left (You can not change directions). You need to figure out the shortest distance you need to walk to get a sum greater than equal to K. If no such answer exists, print -1;
EXAMPLE:
Input
N = 5
A = [1,2,3,4,5]
K = 8
Output
2
Approach
The answer is 2 as [4,5] is the smallest length array that sum greater than equal to K (as 4+5>8)
EXAMPLE:
Input
N = 5
A = [1,1,1,1,1]
K = 6
Output
-1
Approach
No such subarray with sum greater than equal to K exists
CONSTRAINTS:
1 <= N <=10^5
1 <= K <=10^9
1 <= A[i] <=10^5