![]() |
Given a semicircle with radius r, we have to find the largest square that can be inscribed in the semicircle, with base lying on the diameter. Examples: Input: r = 5 Output: 20 Input: r = 8 Output: 51.2 Approach: Let r be the radius of the semicircle & a be the side length of the square.
Below is the implementation of the above approach: C++
Javascript
Output:
20
Time Complexity: O(1) Auxiliary Space: O(1) |
Reffered: https://www.geeksforgeeks.org
DSA |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |