D. Two Sum

209 cases Time limit 1000 ms total Memory 256 MB

Given a list a and a target value k, return "YES" if there exist two different indices i and j such that a[i] + a[j] == k. Otherwise, return "NO".

Constraints:

  • 2 ≤ len(a) ≤ 100
  • -1000 ≤ a[i] ≤ 1000
  • -2000 ≤ k ≤ 2000
  • i ≠ j (must use different indices)

Examples:

f([0, 1, 2, 3, 4, 5, 7, 8, 9], 17) returns "YES" (8 + 9 = 17)

f([0, 1, 2, 3, 4, 5, 7, 8, 9], 18) returns "NO" (no two elements sum to 18)

0 bytes Contest has ended