#C10289. Find Three Numbers Summing to Target

    ID: 39477 Type: Default 1000ms 256MiB

Find Three Numbers Summing to Target

Find Three Numbers Summing to Target

Given an array of integers and a target value, your task is to determine whether there exist three numbers in the array such that their sum equals the target, i.e. (a + b + c = T) where (T) is the target value. If such a triplet exists, output the three integers in ascending order formatted as a Python-style list (for example, [a, b, c]). Otherwise, output an empty list ([]). The input is read from standard input and the output should be printed to standard output.

inputFormat

The first line contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers denoting the elements of the array. The third line contains an integer representing the target value.

outputFormat

Print a single line to the standard output. If a valid triplet is found, print the three numbers in ascending order in the format of a Python list (e.g., [a, b, c]). Otherwise, print an empty list: [].## sample

6
1 2 4 6 8 10
14
[2, 4, 8]