Simple If-else solution | Beginners Friendly | 💯% user's beat
\n\n\n# Approach\nif nums[0]==nums[1]==nums[2]:\nThis line checks if all three sides of the triangle are equal, which would indicate an equilateral triangle.\nr
![Screenshot 2024-02-05 151637.png](https://assets.leetcode.com/users/images/f2544c6a-2633-4539-85c4-c1684a66c7dd_1707126469.3201203.png)\n\n\n# Approach\nif nums[0]==nums[1]==nums[2]:\nThis line checks if all three sides of the triangle are equal, which would indicate an equilateral triangle.\nreturn "equilateral"\n\nIf the condition in line 1 is true, the function returns "equilateral" because all sides are equal.\nelif (nums[0]+nums[2] > nums[1]) and (nums[0]+nums[1] > nums[2]) and (nums[1]+nums[2] > nums[0]):\n\nThis line checks the triangle inequality theorem, which states that the sum of the lengths of any two sides of a triangle must be greater than the length of the third side. If this condition is met, it proceeds to the next block.\nif nums[0]==nums[1] or nums[0]==nums[2] or nums[1]==nums[2]:\n\nWithin the valid triangle condition, this line checks if at least two sides are equal, which would indicate an isosceles triangle.\nreturn "isosceles"\n\nIf the condition in line 4 is true, the function returns "isosceles" because at least two sides are equal.\nelse:\n\nIf the condition in line 4 is false (i.e., the triangle has passed the triangle inequality theorem check but doesn\'t have two equal sides), it means the triangle is scalene.\nreturn "scalene"\n\nIf the condition in line 4 is false, the function returns "scalene" because all three sides are different.\nelse:\n\nIf the condition in line 3 is false (i.e., the triangle inequality theorem check fails), the function returns "none" because the sides provided cannot form a valid triangle.\n\n\n# Code\n```\nclass Solution:\n    def triangleType(self, nums: List[int]) -> str:\n        if nums[0]==nums[1]==nums[2]:\n            return "equilateral"\n        elif (nums[0]+nums[1] > nums[2])  and (nums[0]+nums[2] > nums[1]) and (nums[1]+nums[2] > nums[0]):\n            if nums[0]==nums[1] or nums[0]==nums[2] or nums[1]==nums[2]:\n                return "isosceles"\n            else:\n                return "scalene"\n        else:\n            return "none"\n```
['Python', 'Python3']