This is the link to the question :
here is my solution :
the code is passing all the test cases apart from only the last test case for which it is giving wrong answer.
can you please point out the mistake in my code?
my approach :
-> first of all i have stored all the elements that are common in both the arrays in a vector V.
-> then i have stored the sum between every two such elements in array a in the map a1 and that of array 2 in the map b1.
-> after that i have traversed the V vector and added to my final answer the maximum sum between the current number and the next number which are a part of V. that sum was already stored in a1 for array a and in b1 for array b.