Given three sides of the triangle, find the minimum increase in the length of the side of the triangle to make the area of the triangle non-negative.
Input: a = 3, b = 4, c = 10
With the given sides, the area is negative.
If a is increased to 5 and b to 5, then the area becomes 0, which is not negative.
Input: a = 6, b = 6, c = 10
Approach: Since the area of any triangle is non-negative if the sum of the smallest two sides is always greater than or equal to the third side, hence the following steps should be followed to solve the above problem:
- Sort the three sides in increasing order.
- Check if the sum of the first two sides is greater than or equal to the third side, if it is, then the answer is 0.
- If it is not, then the answer will be (third side – (first side + second side)).
Below is the implementation of the given approach.
- Minimum increment or decrement operations required to make the array sorted
- Maximum area rectangle by picking four sides from array
- Making elements of two arrays same with minimum increment/decrement
- Minimum increment by k operations to make all elements equal
- Minimum range increment operations to Sort an array
- Minimum Increment operations to make Array unique
- Minimum increment operations to make K elements equal
- Minimum Increment / decrement to make array elements equal
- Minimum increment operations to make the array in increasing order
- Minimum number of increment/decrement operations such that array contains all elements from 1 to N
- Minimum number of increment-other operations to make all array elements equal.
- Find subarray with given sum | Set 1 (Nonnegative Numbers)
- Minimum Swaps required to group all 1's together
- Minimum operations required to change the array such that |arr[i] - M| <= 1
- Minimum boxes required to carry all gifts
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.