956. Tallest Billboard Hard
1/**
2 * [956] Tallest Billboard
3 *
4 * 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.
5 * 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.
6 * Return the largest possible height of your billboard installation. If you cannot support the billboard, return 0.
7 *
8 * Example 1:
9 *
10 * Input: rods = [1,2,3,6]
11 * Output: 6
12 * Explanation: We have two disjoint subsets {1,2,3} and {6}, which have the same sum = 6.
13 *
14 * Example 2:
15 *
16 * Input: rods = [1,2,3,4,5,6]
17 * Output: 10
18 * Explanation: We have two disjoint subsets {2,3,5} and {4,6}, which have the same sum = 10.
19 *
20 * Example 3:
21 *
22 * Input: rods = [1,2]
23 * Output: 0
24 * Explanation: The billboard cannot be supported, so we return 0.
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= rods.length <= 20
30 * 1 <= rods[i] <= 1000
31 * sum(rods[i]) <= 5000
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/tallest-billboard/
37// discuss: https://leetcode.com/problems/tallest-billboard/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn tallest_billboard(rods: Vec<i32>) -> i32 {
43 0
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_956() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.