Stable Triangle Perimeter
Preview mode. Log in to edit, run, submit, and save progress.
Stable Triangle Perimeter
A hardware team has support edges of different lengths. A stable triangular bracket requires exactly three edges, and the sum of the two shorter edges must be greater than the longest edge. Choose any three edges to maximize the perimeter of the bracket. If no three edges can form a stable triangle, no bracket can be built. Input Format: You are given an integer array edges. Output Format: Return the largest possible stable triangle perimeter, or 0 if no triangle is possible.
Examples
edges = [2, 1, 2]
5
Explanation: Sorted edges are [1, 2, 2]. The largest valid triple is [1, 2, 2] because 1 + 2 > 2, giving perimeter 5.
Approach hint
Sort rods from largest to smallest.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.