Find Polygon With the Largest Perimeter
A medium-tier problem at 65% community acceptance, tagged with Array, Greedy, Sorting. Reported in interviews at Airtel and 0 others.
You're staring at an array of integers and need to find which subset forms a valid polygon with the largest perimeter. This isn't a classic geometry problem dressed up as code. It's a greedy recognition task that trips candidates who don't see the pattern immediately. Airtel has asked it. The acceptance rate sits at 65%, which means a third of people solve it and a third either miss the trick or overcomplicate it. The trick is understanding when you can skip checking all possible subsets and just pick greedily from the sorted array. If this problem lands on your live assessment and you freeze, StealthCoder runs invisibly and surfaces a working solution in seconds.
Companies that ask "Find Polygon With the Largest Perimeter"
Find Polygon With the Largest Perimeter is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe polygon inequality constraint says the sum of any two sides must exceed the third. Most candidates start writing nested loops to test combinations. Wrong move. Once you sort the array in descending order, you only need to check the largest three consecutive elements. If those three satisfy the constraint, they form a valid polygon, and their sum is maximal because you chose the three biggest valid numbers. The common failure: not realizing that you need to iterate down to find the first valid triple, not just take the top three blindly. Another miss: forgetting that you need at least three elements and that invalid polygons can be skipped entirely. Sorting plus a linear scan replaces brute force. Array and Greedy are the core patterns here, and Prefix Sum can optimize sum queries if you're doing extended checks. When you hit this live and haven't drilled the pattern, StealthCoder is your safety net.
Pattern tags
You know the problem.
Make sure you actually pass it.
Find Polygon With the Largest Perimeter recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find Polygon With the Largest Perimeter interview FAQ
What makes this a greedy problem and not dynamic programming?+
Greedy works because sorting the array in descending order guarantees that the largest valid triple you find is globally optimal. You don't need to explore all subsets. DP would be overkill and slower. Once you understand the polygon inequality in sorted context, greedy dominates.
Why do I only need to check three consecutive elements after sorting?+
In descending order, if three consecutive elements fail the polygon test, all larger triples already checked pass, and all smaller triples will fail too. The constraint simplifies: if the two smaller sides sum to more than the largest side, it's valid. Checking beyond the current triple is redundant.
Is this still asked, or is it outdated?+
Airtel has reported it. It's a medium-difficulty problem with a 65% acceptance rate, so it's actively used as a filter. Not a household name like Two Sum, but the pattern is relevant: sort, iterate, greedily pick. It shows up in coding rounds where interviewers want to see if you can recognize when brute force is unnecessary.
What's the most common mistake candidates make?+
Taking the three largest elements without checking if they form a valid polygon, or writing O(n^3) code to test all triples. Both fail. The first gives a wrong answer if the top three don't satisfy the inequality. The second times out. The trick is combining sort and linear iteration so you find the answer in one pass.
How do Sorting and Array topics tie into this problem?+
Sorting is the key unlock. Sorting descending lets you greedily pick from largest values first, turning the search into a linear scan instead of exhaustive search. Array is just the input container. The real insight is that sorting restructures the problem space so greedy becomes optimal.
Want the actual problem statement? View "Find Polygon With the Largest Perimeter" on LeetCode →