✅Beats 100% || Classifying triangles in Java, Python & C++
Intuition\nThe code checks the validity of a triangle based on its side lengths and classifies it as equilateral, isosceles, scalene, or none.\n\n# Approach\nTh
# Intuition\nThe code checks the validity of a triangle based on its side lengths and classifies it as equilateral, isosceles, scalene, or none.\n\n# Approach\nThe approach involves using conditional statements to check the triangle\'s validity and then determining its type based on the side lengths.\n\n# Complexity\n- Time complexity:\nThe time complexity of this solution is O(1) since the code involves a fixed number of comparisons and conditions\n\n- Space complexity:\nThe space complexity is O(1) as there is no additional space used that scales with the input size. \n\n```Java []\nclass Solution {\n    public String triangleType(int[] nums) {\n        \n        if(nums[0]+nums[1]<=nums[2] || nums[1]+nums[2]<=nums[0] || nums[0]+nums[2]<=nums[1])\n            return "none";\n        else if (nums[0] == nums[1] && nums[1] == nums[2])\n            return "equilateral";\n        else if(nums[0]==nums[1] || nums[1]==nums[2] || nums[2]==nums[0])\n            return "isosceles";\n        else \n            return "scalene";\n\n    }\n}\n```\n```python []\nclass Solution:\n    def triangleType(self, nums: List[int]) -> str:\n        if nums[0] + nums[1] <= nums[2] or nums[1] + nums[2] <= nums[0] or nums[0] + nums[2] <= nums[1]:\n            return "none"\n        elif nums[0] == nums[1] == nums[2]:\n            return "equilateral"\n        elif nums[0] == nums[1] or nums[1] == nums[2] or nums[2] == nums[0]:\n            return "isosceles"\n        else:\n            return "scalene"\n\n```\n```C++ []\nclass Solution {\npublic:\n    string triangleType(vector<int>& nums) {\n        if (nums[0] + nums[1] <= nums[2] || nums[1] + nums[2] <= nums[0] || nums[0] + nums[2] <= nums[1])\n            return "none";\n        else if (nums[0] == nums[1] && nums[1] == nums[2])\n            return "equilateral";\n        else if (nums[0] == nums[1] || nums[1] == nums[2] || nums[2] == nums[0])\n            return "isosceles";\n        else\n            return "scalene";\n    }\n};\n```\n\nIf you found this content helpful, consider giving it an **upvote** and share your thoughts in the comments.\n
['Python', 'C++', 'Java']