Courses
Tutorials
Interview Prep
DSA
Practice Problems
C
C++
Java
Python
JavaScript
Data Science
Machine Learning
Courses
Linux
DevOps
Similar Topics
Web Technologies
32.1K+ articles
DSA
20.4K+ articles
Arrays
4.2K+ articles
Amazon
1.9K+ articles
Sorting
1.1K+ articles
Searching
1.0K+ articles
Hash
831+ articles
Microsoft
811+ articles
Accolite
305+ articles
two-pointer-algorithm
213+ articles
2Sum
8 posts
Recent Articles
4 Sum - Count quadruplets with given sum in an array
Last Updated: 23 July 2025
Given an array arr[] and a target value, the task is to find the count of quadruplets present in the given array having sum equal to the given target.Examples:Input: arr[]...
read more
Searching
Hash
DSA
Arrays
interview-preparation
HashTable
cpp-unordered_map
cpp-map
2Sum
3Sum
4Sum
Find all pairs with a given sum in two unsorted arrays
Last Updated: 23 July 2025
Given two unsorted arrays of distinct elements, the task is to find all pairs from both arrays whose sum is equal to a given value X.Examples:Input: arr1[] = {-1, -2, 4, -...
read more
Hash
DSA
Arrays
Amazon
Facebook
2Sum
2 Sum - Count pairs with given sum
Last Updated: 06 August 2025
Given an array arr[] of n integers and a target value, find the number of pairs of integers in the array whose sum is equal to target.Examples:Input: arr[] = [1, 5, 7, -1,...
read more
Hash
DSA
Arrays
Amazon
Accolite
Hike
FactSet
2Sum
2 Sum - Pair Sum Closest to Target using Binary Search
Last Updated: 23 July 2025
Given an array arr[] of n integers and an integer target, the task is to find a pair in arr[] such that it’s sum is closest to target.Note:Return the pair in sorted order ...
read more
Searching
Sorting
DSA
Arrays
Binary Search
two-pointer-algorithm
2Sum
Count pairs with absolute difference equal to k
Last Updated: 23 July 2025
Given an array arr[] and a positive integer k, the task is to count all pairs (i, j) such that i j and absolute value of (arr[i] - arr[j]) is equal to k.Examples:Input: a...
read more
Sorting
Hash
DSA
Arrays
Amazon
Adobe
Facebook
Arrays
Hash
2Sum
4 Sum - All Distinct Quadruplets with given Sum in an Array
Last Updated: 13 August 2025
Given an array arr[], and an integer target, find all possible unique quadruplets in an array whose sum is equal to the given target value. We can return quadruplets in an...
read more
Sorting
Hash
DSA
Arrays
Microsoft
Amazon
Google
two-pointer-algorithm
2Sum
3Sum
Pair Sum Closest to 0
Last Updated: 19 April 2026
Given an integer array arr[], find the sum of any two elements whose sum is closest to zero. Note: In case if we have two ways to form sum closest to zero, return the maxi...
read more
Searching
DSA
Arrays
Microsoft
Amazon
Fab.com
Snapdeal
Accolite
two-pointer-algorithm
2Sum
Two Sum - Pair with given Sum
Last Updated: 26 July 2025
Given an array arr[] of n integers and a target value, check if there exists a pair whose sum equals the target. This is a variation of the 2-Sum problem.Examples:Input: a...
read more
Backtracking
Hash
Recursion
DSA
Arrays
Microsoft
Amazon
Morgan Stanley
Flipkart
Accolite
Zoho
Hike
SAP Labs
CarWale
FactSet
Infosys
Amazon-Question
CarWale-Question
ABCO
Wipro
2Sum