#C12183. Two Sum Problem

    ID: 41582 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers and a target integer, determine if there exist two distinct indices i and j in the array such that their corresponding elements sum up to the target value. In other words, find if there exist indices i and j (i \neq j) satisfying the equation: $$a_i + a_j = target$$. Input is read from standard input (stdin) and the answer is output to standard output (stdout).

inputFormat

The input consists of three lines:

  1. The first line contains a single integer n, representing the number of elements in the array.
  2. The second line contains n space-separated integers, representing the elements of the array.
  3. The third line contains a single integer, representing the target value.

outputFormat

Output a single line containing either True or False (case-sensitive) indicating whether there exists a pair of distinct indices in the array such that the sum of the corresponding elements equals the target.## sample

4
1 2 3 4
5
True