![]() |
VOOZH | about |
Given the other two sides of a right angled triangle, the task is to find it's hypotenuse.
Examples:
Input: side1 = 3, side2 = 4
Output: 5.00
32 + 42 = 52
Input: side1 = 12, side2 = 15
Output: 19.21
Approach:Pythagoras theorem states that the square of hypotenuse of a right angled triangle is equal to the sum of squares of the other two sides.
Below is the implementation of the above approach:
5.00
Time Complexity: O(log(2*(s2)) where s is the side of the rectangle. because time complexity of inbuilt sqrt function is O(log(n))
Auxiliary Space: O(1)