https://leetcode.com/problems/type-of-triangle/description/
LeetCode - The World's Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
1
2
3
4
5
6
7
8
9
10
11
12
|
class Solution:
def triangleType(self, nums: List[int]) -> str:
nums.sort()
if sum(nums) - max(nums) <= max(nums):
return 'none'
elif nums[0] == nums[1] and nums[1] == nums[2]:
return 'equilateral'
elif nums[0] == nums[1] or nums[1] == nums[2]:
return 'isosceles'
else:
return 'scalene'
|
cs |
삼각형 성립 조건 입니다
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 1732. Find the Highest Altitude (1) | 2024.02.15 |
---|---|
leetcode 2784. Check if Array is Good (0) | 2024.02.14 |
leetcode 3033. Modify the Matrix (1) | 2024.02.13 |
leetcode 2357. Make Array Zero by Subtracting Equal Amounts (1) | 2024.02.09 |
leetcode 2586. Count the Number of Vowel Strings in Range (0) | 2024.02.09 |
댓글