
Asked in Blackrock
Ninja And The Triangle Problem Statement
Ninja is provided with 'N' stars and the task is to construct a triangle such that the 'i'th level of the triangle uses 'i' number of stars. The goal is to make the triangle as tall as possible using the given stars.
Example:
Input:
N = 6
Output:
3
Explanation:
With 6 stars, Ninja can build a triangle with a maximum height of 3 levels: 1+2+3 = 6 stars.
Constraints:
- 1 <= T <= 100
- 1 <= N <= 10^8
Input:
The first line contains an integer 'T', the number of test cases. Each of the next 'T' lines contains a single integer 'N', the number of stars available.
Output:
For each test case, output a single integer representing the maximum height of the triangle possible with the given stars. Output each result on a separate line.
Note:
No need to print anything. Implement the function to solve the problem.

AnswerBot
4mo
Given 'N' stars, construct a triangle with maximum height using 'i' stars in 'i'th level.
Calculate the maximum height of the triangle using the formula: height = floor((-1 + sqrt(1 + 8 * N)) / 2)
Itera...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Blackrock
Q. Validate Binary Search Tree Problem Statement Your task is to determine if a giv...read more
Q. Bridge in Graph Problem Statement Given an undirected graph with V vertices and ...read more
Q. Shortest Distance in a Binary Search Tree Your task is to determine the shortest...read more
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Blackrock Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

