You have to place an electronic banner of a company as high as it can be, so that whole the city can view the banner standing on top of 2 pillars. The height of two pillars are to be chosen from given array… say [1, 2, 3, 4, 6]. We have to maximize the height of the two pillars standing side by side so that the pillars are of equal height and the banner can be placed on top of it. So for this case, maximum height is 8 and the pillar sets will be: [2,6], [4,3,1]
It is not necessary that all the elements of the array have to be used. Say, Array = [1,2,3,4,7] then maximum height is 7 and sets are , [4,3]
This problem is different from the subset sum problem in Dynamic programming because here all elements need not be part of the solution set.
I am trying to think of an approach to this problem and its extension, if instead of two pillars we have n pillars. Which is, how would the approach differ if we had to find n subsets of an array which are maximum & equal?
This question has a solution on stackoverflow which I am unable to fully grasp:
Please help in understanding the approach and the thought process.