#K63812. Triangle Triplet Check
Triangle Triplet Check
Triangle Triplet Check
Given a list of integers, determine whether there exist three distinct elements (a), (b), and (c) from the list that can form the sides of a triangle. Recall that for three lengths to form a triangle, they must satisfy the triangle inequality: (a + b > c) (after sorting the sides in non-decreasing order).
For example, if the input array is [10, 2, 5, 1, 8, 12], then the sorted order is [1, 2, 5, 8, 10, 12] and one valid triplet that satisfies (a+b>c) is (5, 8, 10). Your task is to decide if such a triplet exists.
inputFormat
The first line of input contains a single integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers representing the elements of the array.
outputFormat
Output a single line with either True
if there exists a triplet forming a triangle according to the triangle inequality, or False
otherwise.## sample
6
10 2 5 1 8 12
True