Loading...
Loading...
Loading...
Given the amounts of several orders and a target amount, print YES if two different orders add up to exactly the target. Otherwise print NO. The amounts are not sorted.
Example 1
Input
8 3 12 5 20 17
Output
YES
Example 2
Input
4 6 8
Output
NO
Try the problem first. Open one hint at a time.
Check, for each amount, whether target - amount was seen before.
Add the amount to the set after checking, so an order never pairs with itself.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor