20250519 finished.
This commit is contained in:
parent
69ff07860e
commit
f838767e30
|
@ -662,3 +662,5 @@ mod p2901_longest_unequal_adjacent_groups_subsequence_ii;
|
|||
mod p75_sort_colors;
|
||||
|
||||
mod p1931_painting_a_grid_with_three_different_colors;
|
||||
|
||||
mod p3024_type_of_triangle;
|
||||
|
|
40
src/problem/p3024_type_of_triangle.rs
Normal file
40
src/problem/p3024_type_of_triangle.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* [3024] Type of Triangle
|
||||
*/
|
||||
pub struct Solution {}
|
||||
|
||||
// submission codes start here
|
||||
|
||||
impl Solution {
|
||||
pub fn triangle_type(nums: Vec<i32>) -> String {
|
||||
if nums[0] + nums[1] <= nums[2]
|
||||
|| nums[0] + nums[2] <= nums[1]
|
||||
|| nums[1] + nums[2] <= nums[0]
|
||||
{
|
||||
return "none".to_string();
|
||||
}
|
||||
|
||||
if nums[0] == nums[1] || nums[0] == nums[2] || nums[1] == nums[2] {
|
||||
if nums[0] == nums[1] && nums[1] == nums[2] {
|
||||
"equilateral".to_string()
|
||||
} else {
|
||||
"isosceles".to_string()
|
||||
}
|
||||
} else {
|
||||
"scalene".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// submission codes end
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_3024() {
|
||||
assert_eq!("equilateral", Solution::triangle_type(vec![3, 3, 3]));
|
||||
assert_eq!("scalene", Solution::triangle_type(vec![3, 4, 5]));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user