Given an array **arr** of size **N** and an integer **K**. The task is to find the pair of integers in the array such that their sum is maximum but less than **K**

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. T testcases follow.

The first line of each test case contains **N** and **K**, where **N** is the number of elements in the array and **K** is the bound. The second line of each test case contains the array elements.

**Output:**

Print the pair with the maximum sum less than **K**.

**Your task:**

You **don't **have to take input. **Complete **the function **Max_Sum()**, which takes the **array, N **and** K** as parameters and **returns **the pair of integer if exist else return pair of zeros (0,0). The **printing**** **is done by the **driver**** **code.

**Constraints:**

1 ≤ T ≤ 10

0 ≤ N ≤ 10^{5}

0 ≤ K ≤ 10^{6}

0 ≤ arr[i] ≤ 10^{5}

**Example:**

**Input:**

2

6 10

2 3 4 6 8 10

6 0

2 3 4 6 8 10

**Output:**

3 6

0 0

**Explanation**:

**Testcase 1**: Pair (3,6) has a maximum sum equals 9 which is less than 10.

**Testcase 2**: There doesn't exist any pair in the array with a sum less than 0.

Author: xenon_shivam

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

murli01 | 343 |

decoder_101 | 274 |

john_wick | 204 |

singhalsaurav1997 | 196 |

Sulagna | 189 |

john_wick | 725 |

PiyushPandey4 | 717 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

decoder_101 | 512 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.