Skip to main content

Tallest Billboard

HardArrayBacktracking

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:6
Explanation:

3+3 or 6.

Input:rods = [1,1,1,1]
Output:2
Explanation:

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:14
Explanation:

The rods can be distributed into two supports of equal height 15, with some rods left unused.

Constraints

  • 1 ≤ rods.length ≤ 20

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.