Math Fundamentals18 sections · 814 units
Open in Course

Valid Triangle - The Idea

(Triangle inequality)

For any triangle, the longest side must be less than the sum of the other two sides. If you sort the sides so a ≤ b ≤ c, you only need to check if a + b > c.

Why does this work? If the two smallest sides sum to more than the largest side, all other combinations automatically pass. The other two inequalities (a + c > b and b + c > a) are guaranteed when a + b > c and sides are sorted.

This reduces three checks to one check after sorting.