Tallest Billboard - Problem

You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.

You are given a collection of rods that can be welded together. For example, if you have rods of lengths 1, 2, and 3, you can weld them together to make a support of length 6.

Return the largest possible height of your billboard installation. If you cannot support the billboard, return 0.

Input & Output

Example 1 — Basic Case
$ Input: rods = [1,2,3,6]
Output: 6
💡 Note: We can build supports of equal height 6: Left support uses rods [1,2,3] with total length 6, Right support uses rod [6] with length 6
Example 2 — No Solution
$ Input: rods = [1,2,3,4]
Output: 0
💡 Note: No way to split rods [1,2,3,4] into two equal-height supports. Total sum is 10, so we need each support to have height 5, but no subset sums to 5
Example 3 — Multiple Solutions
$ Input: rods = [1,2]
Output: 0
💡 Note: Only one rod per support would give heights 1 and 2 (not equal). Cannot make equal heights with these rods

Constraints

  • 1 ≤ rods.length ≤ 20
  • 1 ≤ rods[i] ≤ 1000

Visualization

Tap to expand
Tallest Billboard ProblemBuild two equal-height supports from rods [1,2,3,6]1236Available RodsSplitLeft1+2+3=6Right6=6Support 1Support 2Billboard BaseMaximum Equal Height: 6
Understanding the Visualization
1
Input
Collection of rods with different lengths [1,2,3,6]
2
Process
Split rods into two groups to form equal-height supports
3
Output
Maximum possible height when both supports are equal
Key Takeaway
🎯 Key Insight: Track height differences between supports, not absolute heights, to reduce the state space in dynamic programming.
Asked in
Google 25 Facebook 18 Amazon 12
28.0K Views
Medium Frequency
~45 min Avg. Time
890 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen