Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 750 Bytes

maximum-height-tree.md

File metadata and controls

34 lines (29 loc) · 750 Bytes

Maximum Height Tree

Problem Link

Given N dots that form a triangle such that ith line contains i number of dots.

    .
   . .
  . . .
 . . . .

Find the minimum hieght H of the triangle that can be formed using these N dots.

Sample Input

10

Sample Output

4

Solution

class Solution{
public:
    int height(int N){
        return (-1 + sqrt(1 + 8*N))/2;
    }
};

Accepted

image