Showing:
Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Pick Values
Easy Accuracy: 40.86% Submissions: 142 Points: 2

Given an array arr[] of N positive integers. Select values from the array such that their sum is minimum. You must pick at least 1 value from each group of 4 consecutive elements.

Example 1:

Input:
N = 5
Arr[] = {1, 2, 3, 1, 2}
Output: 1
Explanation: There are 2 groups of 4
in the given array. The 1st group is
[1 2 3 1] and 2nd is [2 3 1 2].
Selecting the 4th element in the
array will give the least sum as
it belongs to both groups.


Example 2:

Input:
N = 6
Arr[] = {8, 6, 9, 10, 6, 7}
Output: 9
Explanation: There are 3 groups of 4
consecutive elements. 9 at index 2
is the smallest element that is
present in all 3 groups.



You don't need to read input or print anything. Your task is to complete the function pickValues() which takes the array of integers arr[] and its size as input parameters and returns an integer denoting the minimum sum.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Constraints:
1 ≤ N ≤ 105
1 ≤ Arr[i] ≤ 103