Find All Four Sum Numbers

easy
1.Given an array A of size N. 2.Find all combination of four elements in the array whose sum is equal to a given value K. 3.For example, if the given array is {10, 2, 3, 4, 5, 9, 7, 8} and K = 23, one of the quadruple is "3 5 7 8" (3 + 5 + 7 + 8 = 23). 4.You have to complete the function findQuads() to print all the combinations else -1 if no combination found.

Input Format

1.The first line of input contains two integers N and K. 2.Then in the next line are N space separated values of the array.

Output Format

1.Print all the quadruples present in the array separated by space which sums up to value of K. Each quadruple is unique which are separated by a delimeter "$" and are in increasing order. 2.Print -1 if no quadruple is found

Constraints

1 <= N <= 100
 -1000 <= K <= 1000
 -100 <= A[] <= 100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5 3
0 0 2 1 1
Output
0 0 1 2 $
Previous
Find Distinct Elements
Next
Equal Zero One And Two

Related Questions