Question: code javascript: Given numbers on a circle, find the maximum number of neighbouring pairs with an even sum. Task description You are given N numbers
code javascript: Given numbers on a circle, find the maximum number of neighbouring pairs with an even sum.
Task description
You are given N numbers on a circle, described by an array A Find the maximum number of neighbouring pairs whose sums are even. One element can belong to only one pair.
Write a function:
function solutionA;
that, given an array A consisting of N integers, returns the maximum number of neighbouring pairs whose sums are even.
Examples:
Given A the function should return We can create two pairs with even sums: A A and A A Another way to choose two pairs is: A A and A A
Given A the function should return There is only one qualifying pair: A A
Given A the function should return We can create three pairs: A AA A and A A
Write an efficient algorithm for the following assumptions:
N is an integer within the range ;
each element of array A is an integer within the range
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
