finding triangulars from array

后端 未结 5 749
一向
一向 2021-01-07 12:58

zero-indexed array A consisting of N integers is given. A triplet (P, Q, R) is triangular if and

A[P] + A[Q] > A[R], 
A[Q] + A[R] > A[P], 
A[R] + A[P         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-07 13:48

    A hint: if you pick just two members of the array then what are the limits on the possible value of the third member of a triangular triplet? Any number outside those limits can be rejected immediately.

提交回复
热议问题