Practice Maximum Height of a Triangle
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
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 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on. All the balls in a particular row should be the same color, and adjacent rows should have different colors. Return the maximum height of the triangle that can be achieved.
Source: Maximum Height of a Triangle on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
red = 2, blue = 4
3
# Example 2
red = 2, blue = 1
2
# Example 3
red = 1, blue = 1
1
# Example 4
red = 10, blue = 1
2
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Height of a Triangle.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.