#K40762. Three Indices Sum Problem
Three Indices Sum Problem
Three Indices Sum Problem
You are given an array of n integers and a target integer T. Your task is to find three distinct indices i, j, and k (with 0-based indexing) such that:
If such a triplet exists, output the three indices (in the order you find them) separated by a single space. If no such triplet exists, output -1
.
Note: If there are multiple valid triplets, output the first one you encounter.
inputFormat
The input is given from the standard input with the following format:
- The first line contains one integer n, the number of elements in the array.
- The second line contains n space-separated integers.
- The third line contains the target integer T.
outputFormat
If there exists a triplet of indices (i, j, k) such that a[i] + a[j] + a[k] = T, print the three indices separated by a single space. Otherwise, print -1
.
6
1 2 3 4 5 6
10
0 3 4
</p>