DEV Community

Miss Pooja Anilkumar Patel
Miss Pooja Anilkumar Patel

Posted on

976. Leetcode solution in python3


class Solution:
  def largestPerimeter(self, A: List[int]) -> int:
    A = sorted(A)

    for i in range(len(A) - 1, 1, -1):
      if A[i - 2] + A[i - 1] > A[i]:
        return A[i - 2] + A[i - 1] + A[i]

    return 0
Enter fullscreen mode Exit fullscreen mode

Leetcode

challenge

Here is the link for the problem:
https://leetcode.com/problems/largest-perimeter-triangle/

Top comments (0)