Close To Zero

1.7

9 votes
Easy
Problem

Problem

Given an array of numbers, find two numbers (index should be different for the two numbers) from the array such that their sum is closest to zero.

  • Note: Print the two numbers in ascending order.

Input

First line contains T denoting the number of test cases. Each test case contains N denoting number of array elements. Then N space separated integers follow in the next line denoting the array elements.

Output

For each test case output in a new line two space separated integers in ascending order denoting the found two numbers as per the problem.

Constraints

  • 1 <= T <= 50
  • 1 <= N <= 104
  • 10-9 <= array elements <= 109

Explanation

-2 and 1 have sum -1 which is the closest to 0 among all pairs of numbers possible from the array.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

-2 and 1 have sum -1 which is the closest to 0 among all pairs of numbers possible from the array.

Editor Image

?