FastPrepTallest Billboard

Tallest Billboard

Amazon logoAmazon● HardINTERNONSITE INTERVIEW
Learn

Problem statement

Partition any subset of rods into two groups with equal sums. Return the greatest possible common sum. A rod may be unused.

Function

tallestBillboard(rods: int[]) → int

Examples

Example 1

rods = [1,2,3,6]return = 6

Use 6 on one side and 1+2+3 on the other.

Example 2

rods = [1,2]return = 0

No positive equal-height partition exists.

Constraints

  • 1 <= rods.length <= 20.
  • 1 <= rods[i] <= 1000.
  • The total length is at most 5000.

Source note: Author-written prompt excerpt retained for source fidelity.

More Amazon problems

See Amazon hiring insights
public int tallestBillboard(int[] rods) {
    // Write your code here.
}
rods[1,2,3,6]
expected6
Checking account…