Class Solution

java.lang.Object
g0901_1000.s0956_tallest_billboard.Solution

public class Solution extends Object
956 - Tallest Billboard.<p>Hard</p> <p>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.</p> <p>You are given a collection of <code>rods</code> that can be welded together. For example, if you have rods of lengths <code>1</code>, <code>2</code>, and <code>3</code>, you can weld them together to make a support of length <code>6</code>.</p> <p>Return <em>the largest possible height of your billboard installation</em>. If you cannot support the billboard, return <code>0</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> rods = [1,2,3,6]</p> <p><strong>Output:</strong> 6</p> <p><strong>Explanation:</strong> We have two disjoint subsets {1,2,3} and {6}, which have the same sum = 6.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> rods = [1,2,3,4,5,6]</p> <p><strong>Output:</strong> 10</p> <p><strong>Explanation:</strong> We have two disjoint subsets {2,3,5} and {4,6}, which have the same sum = 10.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> rods = [1,2]</p> <p><strong>Output:</strong> 0</p> <p><strong>Explanation:</strong> The billboard cannot be supported, so we return 0.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= rods.length <= 20</code></li> <li><code>1 <= rods[i] <= 1000</code></li> <li><code>sum(rods[i]) <= 5000</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • tallestBillboard

      public int tallestBillboard(int[] rods)