3200. Maximum Height of a Triangle Easy

@problem@discussion
#Array#Enumeration



1/**
2 * [3200] Maximum Height of a Triangle
3 *
4 * You are given two integers red and blue representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1^st row will have 1 ball, the 2^nd row will have 2 balls, the 3^rd row will have 3 balls, and so on.
5 * All the balls in a particular row should be the same color, and adjacent rows should have different colors.
6 * Return the maximum height of the triangle that can be achieved.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">red = 2, blue = 4</span>
11 * Output: 3
12 * Explanation:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2024/06/16/brb.png" style="width: 300px; height: 240px; padding: 10px;" />
14 * The only possible arrangement is shown above.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">red = 2, blue = 1</span>
19 * Output: <span class="example-io">2</span>
20 * Explanation:
21 * <img alt="" src="https://assets.leetcode.com/uploads/2024/06/16/br.png" style="width: 150px; height: 135px; padding: 10px;" /><br />
22 * The only possible arrangement is shown above.
23 * </div>
24 * <strong class="example">Example 3:
25 * <div class="example-block">
26 * Input: <span class="example-io">red = 1, blue = 1</span>
27 * Output: <span class="example-io">1</span>
28 * </div>
29 * <strong class="example">Example 4:
30 * <div class="example-block">
31 * Input: <span class="example-io">red = 10, blue = 1</span>
32 * Output: <span class="example-io">2</span>
33 * Explanation:
34 * <img alt="" src="https://assets.leetcode.com/uploads/2024/06/16/br.png" style="width: 150px; height: 135px; padding: 10px;" /><br />
35 * The only possible arrangement is shown above.
36 * </div>
37 *  
38 * Constraints:
39 * 
40 * 	1 <= red, blue <= 100
41 * 
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/maximum-height-of-a-triangle/
46// discuss: https://leetcode.com/problems/maximum-height-of-a-triangle/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51    pub fn max_height_of_triangle(red: i32, blue: i32) -> i32 {
52        0
53    }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn test_3200() {
64    }
65}
66


Back
© 2025 bowen.ge All Rights Reserved.