976. Largest Perimeter Triangle Easy
1/**
2 * [976] Largest Perimeter Triangle
3 *
4 * Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
5 *
6 * Example 1:
7 *
8 * Input: nums = [2,1,2]
9 * Output: 5
10 *
11 * Example 2:
12 *
13 * Input: nums = [1,2,1]
14 * Output: 0
15 *
16 *
17 * Constraints:
18 *
19 * 3 <= nums.length <= 10^4
20 * 1 <= nums[i] <= 10^6
21 *
22 */
23pub struct Solution {}
24
25// problem: https://leetcode.com/problems/largest-perimeter-triangle/
26// discuss: https://leetcode.com/problems/largest-perimeter-triangle/discuss/?currentPage=1&orderBy=most_votes&query=
27
28// submission codes start here
29
30impl Solution {
31 pub fn largest_perimeter(nums: Vec<i32>) -> i32 {
32 0
33 }
34}
35
36// submission codes end
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_976() {
44 }
45}
46
Back
© 2025 bowen.ge All Rights Reserved.