isTriangle

Easy · Conditionals · 4 test cases

Given three integer side lengths, determine if they can form a valid triangle. According to the triangle inequality theorem, the sum of the lengths of any two sides of a triangle must be greater than the length of the third side.

Examples

isTriangle(3, 4, 5) → true
isTriangle(1, 1, 3) → false
isTriangle(7, 10, 5) → true

Starter code

function isTriangle(a, b, c) {

}

Complexity of the optimal solution

Time O(1), space O(1). The function performs a fixed number of additions and comparisons. The complexity is constant.

Solve isTriangle in the browser