Add easy/type_of_triangle.py
This commit is contained in:
parent
1c6922e62d
commit
d5429e9e22
1 changed files with 16 additions and 0 deletions
16
easy/type_of_triangle.py
Normal file
16
easy/type_of_triangle.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# https://leetcode.com/problems/type-of-triangle
|
||||
|
||||
from typing import List
|
||||
|
||||
class Solution:
|
||||
def triangleType(self, nums: List[int]) -> str:
|
||||
[a, b, c] = nums
|
||||
if a == b == c:
|
||||
return "equilateral"
|
||||
s = a + b + c
|
||||
m = max(nums)
|
||||
if s - m <= m:
|
||||
return "none"
|
||||
if a == b or b == c or a == c:
|
||||
return "isosceles"
|
||||
return "scalene"
|
||||
Loading…
Add table
Add a link
Reference in a new issue