Answer: MOBIKWIK Hiring | Largest Perimeter Triangle | On-Campus OA (2024)
Answer · Posted Jun 2026
Approach A triangle is valid if the sum of two smaller sides is greater than the largest side. After sorting the array: Maintain the sum of all previous elements (prefix). For each element, check whether the accumulated sum is greater than the current side. If true, a valid polygon/triangle perimeter can be formed and we update the answer. Keep extending to maximize the perimeter. Strategy Sort the array. Maintain a running prefix sum. If prefix > currentSide, update the maximum ...
The full answer & interview discussion are available to premium members.
Log in Create a free account