Given hypotenuse and area of a right angle triangle, get its base and height and if any triangle with given hypotenuse and area is not possible, print not possible. We can use a property of right angle triangle for solving this problem, which can be stated as follows, Now if given area is less than this maximum area, we can do a binary search for length of base, as increasing base will increases area, it is a monotonically increasing function where binary search can be applied easily.
Output: Time complexity: O(log(n)) because using inbuilt sqrt function One more solution is discussed in below post. Article Tags : |