Java icon indicating copy to clipboard operation
Java copied to clipboard

[FEATURE REQUEST] Add 4-Sum Problem

Open nishchalgv1 opened this issue 1 year ago • 7 comments

What would you like to Propose?

I would like to propose adding an implementation of the 4-Sum Problem under the https://github.com/TheAlgorithms/Java/tree/master/src/test/java/com/thealgorithms/misc section of the repository.

Issue details

Problem Statement: Given an array of N integers, your task is to find unique quads that add up to give a target value. In short, you need to return an array of all the unique quadruplets [arr[a], arr[b], arr[c], arr[d]] such that their sum is equal to a given target.

Example 1: Input Format: arr[] = [1,0,-1,0,-2,2], target = 0 Result: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]] Explanation: We have to find unique quadruplets from the array such that the sum of those elements is equal to the target sum given that is 0. The result obtained is such that the sum of the quadruplets yields 0.

Example 2: Input Format: arr[] = [4,3,3,4,4,2,1,2,1,1], target = 9 Result: [[1,1,3,4],[1,2,2,4],[1,2,3,3]] Explanation: The sum of all the quadruplets is equal to the target i.e. 9.

Additional Information

No response

nishchalgv1 avatar Oct 13 '24 17:10 nishchalgv1

@nishchalgv1 I would like to work on this issue, could u assign me?

vinith-369 avatar Oct 13 '24 19:10 vinith-369

we can solve this by fixing 2 values then using 2 pointers to get other 2 values whose total sum equals to given value and return it

i would like to solve this,please assign it under hacktoberfest tag

Hriishikeshh avatar Oct 14 '24 06:10 Hriishikeshh

/assign

ArifRahaman avatar Oct 14 '24 13:10 ArifRahaman

@nishchalgv1 I want to contribute in it can i??

Krushit-Babariya avatar Oct 15 '24 12:10 Krushit-Babariya

/assign

devDEV03 avatar Oct 18 '24 07:10 devDEV03

/assign

KunjMaheshwari avatar Oct 19 '24 05:10 KunjMaheshwari

Hi, I'd like to work on this issue. Could you please assign it to me?

prabhatsingh415 avatar Oct 20 '24 06:10 prabhatsingh415

/assign

prabhatsingh415 avatar Oct 23 '24 12:10 prabhatsingh415

We do not add Leetcode problems

siriak avatar Oct 23 '24 13:10 siriak