Question: Question 2 2 Max. score: 2 0 . 0 0 orrect pair sum Given an integer array A of the size N . Find the
Question
Max. score:
orrect pair sum
Given an integer array of the size Find the sum of values in the
array that has different parity from that of their index in the array.
Calculate the sum of values of for all i where,
imod
Note: based indexing is used.
Function description
Complete the function solve. This function takes the following
parameters and and returns an integer output:
: Represents the number of array elements
A: Represents the integer array
Input format for custom testing
Note: Use this input format if you are testing against custom input or
writing code in a language where we don't provide boilerplate code.
The first line rontains a sinnle intener I denotina the total Note: Use this input format if you are testing against custom input or
writing code in a language where we don't provide boilerplate code.
The first line contains a single integer denoting the total
number of test cases.
For each test case:
The first line of each test case contains a single integer
The second line of each test case contains space
separated integers representing the array
Output format
For each test case in a new line, print a single integer denoting the
answer to the test case.
Constraints
Sum of for all test cases Sample input
Explanation
The first line contains denoting the number of test cases, here
For the first test case
Given
Approach
For you have mod and imod Do not add it to
the answer.
For you have mod and mod Do not add it
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
