Timeline
Timeline
2025-09-26
init
Multi-loop optimization
Problem:
The fixed routine for this problem is to first fix the largest side, then use two pointers: one from front to back (representing the smallest side) and one from back to front (representing the second largest side). If the sum of the values pointed by the front pointer and the back pointer satisfies the triangle inequality condition, then the smallest side can be any value between the two pointers, and then we can decrease the second largest side to check if it still satisfies. If not, it means the smallest side is too small, so we increase the smallest side. Since it is the smallest side, its value cannot be greater than the second largest side. When the two pointers meet, it means we have traversed all cases where the largest side is the current fixed largest side. Then we decrease the largest side and restart the traversal with the smallest side and the second largest side.
1 |
|
