Maximum Area | Practice | GeeksforGeeks

Given the maximum possible area of the right angle triangle for a fixed length of hypotenuse. The task is to find the length of hypotenuse.
Note: If the answer comes in Decimal, find it's Floor value.
Example 1:
Input:
N = 25
Output:
10
Explanation:
For a maximum area of 25 square Units
of a Right-angled Triangle,
the length of it's Hypotenuse is 10.
Example 2:
Input:
N = 21
Output:
9
Explanation:
For a maximum area of 21 square Units
of a Right-angled Triangle, the
length of it's Hypotenuse is 9.165 = 9.

Your Task:
You don't need to read input or print anything. Your task is to complete the function getHypotenuse() which takes an Integer N as input and returns the answer.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 1010
0
mayank180919995 hours ago
 int getHypotenuse(long long N) {
        // code here
        return floor(2*sqrt(N));
    }
0
birlangirohitkumar20023 months ago
 int getHypotenuse(long long N) {return floor(2*pow(N,0.5));// code here   }
+2
aadeshabhigyan093 months ago
class Solution { public:   int getHypotenuse(long long N) {       // code here              // to get a maximum area out of a right angled triangle, it should be isoceles;        int hyp = sqrt(4*N);   return hyp;   }};
0
deepeshdhaundiyal13 months ago
https://www.doubtnut.com/question-answer/the-maximum-area-of-a-right-angled-triangle-with-hypotenuse-h-is-345490
 
+1
ayeujjawalsingh
This comment was deleted.
+7
ayushnautiyal11103 months ago
Here is My C++ IMPLEMENTATION:)
 
int getHypotenuse(long long N) {       return 2*sqrt(N);   }
MY LOGIC:-😉😉😉😉
 
We have N as an input
By Formula of Area Of Triangle
1⁄2*B*H=A
B*H=2*A
(BY MAXIMA and MINIMA which we studied in class 12)
We came to know when Base is Equal to Height 
Then the Right Angled Triangle is Maximum
SO:
B*B=2*A let is this be eq 1...............
Now By Pythagoras Theorm we know
HP*HP = B*B+H*H 
By applying Maxima condition we get
HP*HP=2*B*B let us consider this be eq 2
Putting the value if B*B from eq1 to eq2
we get
HP*HP=2*2*A
HP*HP=4*A
Hence 
HP =2*sqrt(A)
So we get the Hypotensis Of Maximum Area Of Right Angled Triangle Using The concept of MAXIMA and MINIMA and Pythagorus Theorm
 
Hope You Like Logic
 
!!!!!!!  HAPPY CODING GUYS   !!!!!!!!!
 
 
 
+2
harshitd8914 months ago
//Code Cpp
return floor(sqrt(N*4));
+1
shreyanshgupta1384 months ago
 int getHypotenuse(long long N) {       // code here       int r,s;       r=2*sqrt(N);       s=floor(r);       return s;          }
0
skp12424 months ago
1 line soln.return floor(sqrt(4*N));
0
ervishnu19944 months ago
   static int getHypotenuse(Long N) {       return (int)(Math.sqrt(N)+Math.sqrt(N));   }
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.