You are given three sides of a valid triangle. Your task is to classify the triangle both by its sides and by its angles.
Classify the triangle by sides as Equilateral, Isosceles, or Scalene, based on the equality of its sides.
Classify the triangle by angles as Right, Acute, or Obtuse, using the relationship between the squares of the sides. Let the largest side be (c), and the other two sides be (a) and (b).
Input: a = 3, b = 4, c = 5
Output: Scalene, Right
Explanation: No sides are equal, and 3² + 4² = 5², forming a right triangle.
Input: a = 5, b = 5, c = 5
Output: Equilateral, Acute
Explanation: All sides are equal, and every angle is 60°, making the triangle acute.
Input: a = 5, b = 5, c = 9
Output: Isosceles, Obtuse
Explanation: Two sides are equal, and 9² > 5² + 5², so the triangle is obtuse.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
3 4 5
Scalene, Right
5 5 5
Equilateral, Acute