• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
June 14, 2024 |22.0K Views

SDE Sheet - Find all four sum numbers

Description
Discussion

This video is part of the Hashing section under GFG SDE Sheet.

Given an array A of integers and another number K. Find all the unique quadruple from the given array that sums up to K.

Also note that all the quadruples which you return should be internally sorted, ie for any quadruple [q1, q2, q3, q4] the following should follow: q1 <= q2 <= q3 <= q4.

Example 1:

Input: N = 5, K = 3 
A[] = {0,0,2,1,1} 
Output: 0 0 1 2 
Explanation: Sum of 0, 0, 1, 2 is equal to K.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/find-all-four-sum-numbers1732/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link:  https://www.geeksforgeeks.org/find-four-elements-that-sum-to-a-given-value-set-2/