Twin Arrays: Hackerrank
Twin Arrays : You are given two arrays and each containing integers. You need to choose exactly number from A and exactly number from B such that the index of the two chosen numbers is not same and the sum of the 2 chosen values is minimum.
Your objective is to find and print this minimum value.
For example in the image shown below is the minimum sum.
The first line contains an integer denoting the size of two arrays.
Each of the next two lines contains space separated integers denoting array and respectively.
Print the minimum sum which can be obtained under the conditions mentioned in the problem statement.
Sample Input 0
5 5 4 3 2 1 1 2 3 4 5
Sample Output 0
Minimum sum will be obtained by chosing number at the last index of first array and first index of the second array, i.e. .
Tried it. Not able to pass test case #2. Used TreeMaps to store data.