3024. Type of Triangle Easy

@problem@discussion
#Array#Math#Sorting



1/**
2 * [3024] Type of Triangle
3 *
4 * You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.
5 * 
6 * 	A triangle is called equilateral if it has all sides of equal length.
7 * 	A triangle is called isosceles if it has exactly two sides of equal length.
8 * 	A triangle is called scalene if all its sides are of different lengths.
9 * 
10 * Return a string representing the type of triangle that can be formed or "none" if it cannot form a triangle.
11 *  
12 * <strong class="example">Example 1:
13 * 
14 * Input: nums = [3,3,3]
15 * Output: "equilateral"
16 * Explanation: Since all the sides are of equal length, therefore, it will form an equilateral triangle.
17 * 
18 * <strong class="example">Example 2:
19 * 
20 * Input: nums = [3,4,5]
21 * Output: "scalene"
22 * Explanation: 
23 * nums[0] + nums[1] = 3 + 4 = 7, which is greater than nums[2] = 5.
24 * nums[0] + nums[2] = 3 + 5 = 8, which is greater than nums[1] = 4.
25 * nums[1] + nums[2] = 4 + 5 = 9, which is greater than nums[0] = 3. 
26 * Since the sum of the two sides is greater than the third side for all three cases, therefore, it can form a triangle.
27 * As all the sides are of different lengths, it will form a scalene triangle.
28 * 
29 *  
30 * Constraints:
31 * 
32 * 	nums.length == 3
33 * 	1 <= nums[i] <= 100
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/type-of-triangle/
39// discuss: https://leetcode.com/problems/type-of-triangle/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn triangle_type(nums: Vec<i32>) -> String {
45        String::new()
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_3024() {
57    }
58}
59


Back
© 2025 bowen.ge All Rights Reserved.