611. Valid Triangle Number
The obvious solution is to enumerate all possible solutions which costs O(n³). 1000³ = 10⁹ will produce a TLE. For faster lookup, we can always sort it and using binary search.
Assume the three sides are a, b, c where a <= b <= c
. If we’ve known a and b…