Description
Given an array of rod lengths, find the maximum height of two supports of equal height using disjoint subsets of rods.
Examples
Input:
rods = [1,2,3,6]Output:
6Explanation:
3+3 or 6.
Input:
rods = [1,1,1,1]Output:
2Explanation:
Two rods of length 1 for each support gives equal height 2. The maximum equal height is 2.
Input:
rods = [2,4,6,8,10]Output:
15Explanation:
The rods can be distributed into two supports of equal height 15, with some rods left unused.
Constraints
- •
1 ≤ rods.length ≤ 20