Skip to content

Commit 8b1d818

Browse files
committed
Time: 2 ms (2.67%), Space: 41.9 MB (74.91%) - LeetHub
1 parent 3a95d04 commit 8b1d818

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.*;
2+
3+
class Solution {
4+
public String triangleType(int[] nums) {
5+
Arrays.sort(nums);
6+
Set<Integer> set = new HashSet<>();
7+
for (int num : nums) set.add(num);
8+
9+
if (nums[0] + nums[1] <= nums[2]) return "none";
10+
if (set.size() == 1) return "equilateral";
11+
if (set.size() == 2) return "isosceles";
12+
return "scalene";
13+
}
14+
}

0 commit comments

Comments
 (0)