Dsa
Two Pointers
Warm-up
Bridge Stability
An engineering team needs to find exactly two support beams that, when combined, provide a specific total load capacity. They have a list of available beams sorted by their capacity. Determine if any two distinct beams sum up to the target capacity.
Input Format:
First line: A space-separated list of sorted integers (beam capacities).
Second line: A single integer (the target capacity).
Output Format:
Print 'YES' if a pair exists, otherwise print 'NO'.
Example:
Input:
10 20 30 40 50
60
Output: YES
(Explanation: 10+50 or 20+40 equals 60)
Key concepts
two_pointersarray
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now