Problem Statement | |||||||||||||
Three numbers x, y and z are said to satisfy the triangle inequality if x + y > z, x + z > y, and y + z > x. The sequence of integers b[0], b[1], ..., b[n-1] is said to be triangular if b[i], b[j] and b[k] satisfy the triangle inequality for all distinct values of i, j and k. You are given an integer sequence as a int[] a. Return the length of the longest subsequence of a that is triangular. A subsequence of a sequence is obtained by removing zero or more elements from the sequence. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | a will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of a will be between 1 and 10^9, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|