Question: Complete the function solve in Python3 language. code snippets and question is clearly attached along with input and expected output. Question 2 Max. score: 50.00

Complete the function solve in Python3 language. code snippets and question is clearly attached along with input and expected output.  Complete the function solve in Python3 language. code snippets and question
is clearly attached along with input and expected output. Question 2 Max.
score: 50.00 Maximize the number of subarrays You are given an array
of n non negative elements. We can do atmost k swaps on
the array. The swaps need not to be adjacent. Then we will

Question 2 Max. score: 50.00 Maximize the number of subarrays You are given an array of n non negative elements. We can do atmost k swaps on the array. The swaps need not to be adjacent. Then we will divide the array into some contiguous disjoint subarrays. Your goal is to maximize the number of subarrays with an even sum. Example Consider n = 4, k = 1, arr[] = [1, 2, 3, 4). Let's swap the array element arr[2] with arr[3] (consider 1-based indexing). The new array is arrc = (1,3, 2, 4). . The division of subarray is 1.3 124 There is a total of 3 subarrays with an even sum. Function description Complete the solve function provided in the editor. This function takes the following Function description Complete the solve function provided in the editor. This function takes the following 3 parameters and returns the count of even subarray: n: Represents the size of array arr k. Represents the number of swaps. arr. Represents the elements of the array. Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). The first line contains a single integer t which denotes the number of test cases. t also denotes the number of times you have to run the solve function on a different set of inputs. For each test case, First line contains 2 space-separated integers n and k. Next line contains n space-separated integers denoting the array elements. Output format ? For each test case, print a single line denoting the number of maximum possible Output format For each test case, print a single line denoting the number of maximum possible subarrays with an even sum achievable with at most k swaps. Constraints 1st

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!