Tap here to switch tabs
Problem
Submissions

Problem: Maximum Height of a Triangle

med
30 min
Try to solve the Maximum Height of a Triangle problem.

Statement

You are given two integers red and blue, representing the count of red and blue balls available.

You want to build a triangle of balls to achieve the maximum possible height subject to the following conditions:

  • The 1extst1^{ ext{st}} row has 11 ball, the 2extnd2^{ ext{nd}} row has 22 balls, the 3extrd3^{ ext{rd}} row has 33 balls, and in general, the iextthi^{ ext{th}} row has ii balls.

  • Every ball in a single row must share the same color.

  • Consecutive rows must alternate in color.

Return the maximum height of a triangle that can be constructed.

Constraints:

  • 1≤1 \leq red, blue ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Height of a Triangle

med
30 min
Try to solve the Maximum Height of a Triangle problem.

Statement

You are given two integers red and blue, representing the count of red and blue balls available.

You want to build a triangle of balls to achieve the maximum possible height subject to the following conditions:

  • The 1extst1^{ ext{st}} row has 11 ball, the 2extnd2^{ ext{nd}} row has 22 balls, the 3extrd3^{ ext{rd}} row has 33 balls, and in general, the iextthi^{ ext{th}} row has ii balls.

  • Every ball in a single row must share the same color.

  • Consecutive rows must alternate in color.

Return the maximum height of a triangle that can be constructed.

Constraints:

  • 1≤1 \leq red, blue ≤100\leq 100