Quiz: Arrays

Let’s attempt this quiz to test what we’ve learned so far about arrays.

We'll cover the following

Question

Given two arrays in increasing order, find the maximum sum by choosing a few consecutive elements from one array and then a few elements from another array. We can switch arrays at transition points, when the element value is the same in both arrays.

Input

arr1 = [12, 13, 18, 20, 22, 26, 70]

arr2 = [11, 15, 18, 19, 20, 26, 30, 31]

Output

//Max Sum elements: 11, 15, 18, 19, 20, 22, 26, 70 

Max Sum: 201

Exercise

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.