#C9170. Distinct Triplet Sum
Distinct Triplet Sum
Distinct Triplet Sum
Given an array of integers and a target integer, determine if there exist three distinct indices (i, j, k) such that (a_i + a_j + a_k = target). This problem is an extension of the classic 3-Sum problem. You need to read input from standard input (stdin) and output the result to standard output (stdout) as either True
or False
.
inputFormat
The input consists of three lines:
1. The first line contains an integer n
, the number of elements in the array.
2. The second line contains n
space-separated integers representing the array.
3. The third line contains the target integer.
outputFormat
Output a single line: True
if there exists a triplet of distinct elements that sums to the target, otherwise False
.## sample
5
1 2 3 4 5
9
True