Problems > Can It Be a Triangle > Editorial

Can It Be a Triangle — Solution & Editorial

Back to the Problem

Sort the sides; a triangle exists iff the two smaller sides sum to strictly more than the largest.

Complexity: O(1)

Watch out: A + B can overflow 64 bits only if you add three values — compare two at a time, and use strict inequality.