Given n numbers find minimum perimeter triangle
问题 Encountered this problem in coding contest. Could think only O(n^2 log(n)) solution. I guess the expected was O(n log n). I am given n numbers, I have to find 3 numbers that follow triangle inequality and have the smallest sum. I hope this is quite easy to understand. Eg. 10,2,5,1,8,20 Answer is 23 = (5+8+10) 回答1: The longest side should be the successor of the second longest; otherwise, we could shrink the longest and thus the perimeter. Now you can use your binary search to find the third