Given the length, breadth, and height of a cuboid, the task is to find the length of the longest rod that can fit in a cuboid.
Input: length = 12, breadth = 9, height = 8 Output: 17 Input: length = 22, breadth = 19, height = 8 Output: 30.1496
Explanation: In the figure
GH = length, GF = breadth, FB= height
The length of the longest rod is BH. Therefore to compute BH we can apply Pythagoras Theorem in Triangle BHF. From triangle HGF we can compute the length of FH.
After getting the length of FH we can find the length of BH using Pythagoras theorem in triangle BHF.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Longest rod that can be inserted within a right circular cylinder
- Divide cuboid into cubes such that sum of volumes is maximum
- Percentage increase in the volume of cuboid if length, breadth and height are increased by fixed percentages
- Maximum number of 2x2 squares that can be fit inside a right isosceles triangle
- Maximum number of squares that can fit in a right angle isosceles triangle
- Program for Volume and Surface Area of Cuboid
- Maximize volume of cuboid with given sum of sides
- Python | Percentage increase in the total surface area of the cuboid
- Find maximum volume of a cuboid from the given perimeter and area
- Lexicographically smallest permutation of a string that can be reduced to length K by removing K-length prefixes from palindromic substrings of length 2K
- Finding the best fit rectangle that covers a given point
- Area of a largest square fit in a right angle triangle
- Largest subset of rectangles such that no rectangle fit in any other rectangle
- Find side of Square which makes minimal area to fit two identical rectangles inside it
- Length of longest subarray of length at least 2 with maximum GCD
- Number of ways to cut a stick of length N into in even length at most K units long pieces
- Minimize number of cuts required to break N length stick into N unit length sticks
- Longest substring whose characters can be rearranged to form a Palindrome
- First N natural can be divided into two sets with given difference and co-prime sums
- Number of ways a convex polygon of n+2 sides can split into triangles by connecting vertices
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.