Question: Trailhead is a learning platform and for every trail that you complete, you earn a badge. There are two colour of badges based on the

Trailhead is a learning platform and for every trail that you complete, you earn a badge.
There are two colour of badges based on the difficulty level of the trail.
You are very passionate about these badges, and like arranging them in a triangle as follows:
You put 1 red badge in the 1St row, then put 2 blue badges in the 2nd row, then 3 red in the 3rd row and so on.
If the row of your triangle will not suffice from the badges available, that row will not be counted in the height. This keeps you striving to learn more.
Whenever one colour of your badges get over, and you have more badges of the other, you could either make the next row with it if possible or simply make another similar triangle with only the colour left, whichever maximises the height sum of both triangles.
Can you tell him the sum of maximum possible heights of the triangles for N red badges and M blue badges?
given N,M <= Max_INT
for n =4 m =6, ans is 5. need c++ code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!