Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Type of Triangle

XPChallenge Points: 10
levelLevel: Easy

You are given an array nums of three integers, representing the lengths of three sides.
Your task is to determine whether these sides can form a valid triangle.

A triangle is valid only if the sum of any two sides is greater than the remaining side.

If the triangle is valid:

  • It is equilateral when all three sides have the same value.

  • It is isosceles when exactly two sides are equal.

  • It is scalene when all three sides are distinct.

If the three numbers cannot satisfy the triangle inequality rule, return "none".

Example 1:

Input: nums = [5, 5, 8]

Output: "isosceles"

Explanation:

Two sides are equal, and it satisfies triangle rules.

Example 2:

Input: nums = [2, 3, 10]

Output: "none"

Explanation:

2 + 3 = 5 is NOT greater than 10 → cannot form a triangle.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result