Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3024 - Type of Triangle\.

    Easy

    You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.

    • A triangle is called equilateral if it has all sides of equal length.

    • A triangle is called isosceles if it has exactly two sides of equal length.

    • A triangle is called scalene if all its sides are of different lengths.

    Return a string representing the type of triangle that can be formed or "none" if it cannot form a triangle.

    Example 1:

    Input: nums = 3,3,3

    Output: "equilateral"

    Explanation: Since all the sides are of equal length, therefore, it will form an equilateral triangle.

    Example 2:

    Input: nums = 3,4,5

    Output: "scalene"

    Explanation:

    nums0 + nums1 = 3 + 4 = 7, which is greater than nums2 = 5.

    nums0 + nums2 = 3 + 5 = 8, which is greater than nums1 = 4.

    nums1 + nums2 = 4 + 5 = 9, which is greater than nums0 = 3.

    Since the sum of the two sides is greater than the third side for all three cases, therefore, it can form a triangle.

    As all the sides are of different lengths, it will form a scalene triangle.

    Constraints:

    • nums.length == 3

    • 1 <= nums[i] <= 100

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String triangleType(IntArray nums)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait