Skip to content

Commit

Permalink
feat(leetcode): add No.3024
Browse files Browse the repository at this point in the history
  • Loading branch information
mickey0524 committed Mar 27, 2024
1 parent c2a66c6 commit 7fb7adf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions 3024.Type-of-Triangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// https://leetcode.com/problems/type-of-triangle/description/
// algorithms
// Easy (38.4%)
// Total Accepted: 35.3K
// Total Submissions: 91.9K


class Solution {

public String triangleType(int[] nums) {
if (nums[0] + nums[1] <= nums[2]) {
return "none";
}

if (nums[1] + nums[2] <= nums[0]) {
return "none";
}

if (nums[2] + nums[0] <= nums[1]) {
return "none";
}

if ((nums[0] == nums[1]) && (nums[1] == nums[2])) {
return "equilateral";
}

Set<Integer> set = new HashSet<>();
set.add(nums[0]);
set.add(nums[1]);
set.add(nums[2]);

return set.size() == 2 ? "isosceles" : "scalene";
}

}

0 comments on commit 7fb7adf

Please sign in to comment.