Maximum Perimeter Triangle

  • + 0 comments

    Python 3 solution:

    import typing
    
    
    def maximumPerimeterTriangle(
        sticks: list[int],
    ) -> tuple[int, int, int] | tuple[typing.Literal[-1]]:
        sticks.sort(reverse=True)
        for i in range(len(sticks) - 2):
            a, b, c = sticks[i : i + 3]
            if a < b + c:
                return c, b, a
        return (-1,)