Skip to content

Practice Largest Perimeter Triangle

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#976
LeetCode Problem

Largest Perimeter Triangle

Problem Statement

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.

Source: Largest Perimeter Triangle on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,1,2]
Output
5

# Example 2

Input
nums = [1,2,1,10]
Output
0

Constraints

3 <= nums.length <= 10^4
1 <= nums[i] <= 10^6

Related LeetCode Problems

Practice more problems similar to Largest Perimeter Triangle.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.