#C6434. Two Sum Problem

    ID: 50194 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

In this problem, you are given an array of integers (nums) and an integer (target). Your task is to determine if there exist two distinct indices (i) and (j) such that (nums[i] + nums[j] = target). If such a pair exists, output the indices separated by a space (0-indexed); otherwise, output (-1).

The input consists of multiple test cases. For each test case, you are given the size of the array and the target value, followed by the list of integers. Solve the problem efficiently using an appropriate algorithm.

inputFormat

The input begins with an integer (T) indicating the number of test cases. Each test case consists of two lines:
1. The first line contains two integers: (n) (the number of elements in the array) and (target).
2. The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

For each test case, print a single line. If a valid pair is found, output the indices (i) and (j) (0-indexed) separated by a space. If no such pair exists, output (-1).## sample

3
4 9
2 7 11 15
3 6
3 2 4
3 10
3 5 -3
0 1

1 2 -1

</p>