Question
Three arrays of same or different size are given. A happy triplet is defined as the triplet such that |maximum-minimum| in that triplet is the minimum of all the triplet. A triplet should be select in such a way that it contain one element from the given three arrays. If there are two or more triplets with same minimum difference then the triplet with the smallest sum of elements should be print.Print the triplet in decreasing order.
Example:1
array1=[5,2,8]
array2=[10,7,12,14]
array3=[9,14,6]
output: [7,6,5]
Explanation: The triplet [5,7,6] has the mimimum difference |7-5|=2 as compare to all other triplets present.(5 is from array1, 7 is from array2, 6 is from array3)
Example:2
array1=[3,2,6]
array2=[4,3,8]
array3=[6,5,4]
output: [4,3,2]
Explanation: The triplet [3,4,5] and [2,3,4] has the same mimimum difference of 2.
But the triplet [2,3,4] has the minimum sum so return this triplet.
constraint: 1<=n<=10^5