![]() |
Given a semicircle with radius r, we have to find the largest triangle that can be inscribed in the semicircle, with base lying on the diameter. Input: r = 5 Output: 25 Input: r = 8 Output: 64
Approach: From the figure, we can clearly understand the biggest triangle that can be inscribed in the semicircle has height r. Also, we know the base has length 2r. So the triangle is an isosceles triangle.
Below is the implementation of above approach: C++
Javascript
Output:
25
Time complexity: O(1) as it is performing constant operations Auxiliary Space: O(1) |
Reffered: https://www.geeksforgeeks.org
Mathematical |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |