C++
\nclass Solution {\npublic:\n    int largestPerimeter(vector<int>& nums) {\n        \n        // declare variables\n        int n = nums.size();\n        int pr
```\nclass Solution {\npublic:\n    int largestPerimeter(vector<int>& nums) {\n        \n        // declare variables\n        int n = nums.size();\n        int prev = n-3; // the smallest side of the triangle\n        int next = n-2; // the second largest side of the triangle\n        int last = n-1; // the largest side of the triangle\n        \n        sort(nums.begin(), nums.end()); // sorting an array\n        \n        while(nums[prev] + nums[next] <= nums[last]) { // The triangle inequality must be satisfied\n            last--;\n            next--;\n            prev--;\n            if(prev < 0) return 0; // if no such triple is found, return 0 as given in the condition\n        }\n        return nums[prev]+nums[next]+nums[last]; // return the perimeter\n    }\n};\n```\n
['C']