Find all Pairs Whose Sum is Equal to Given Number

Find All Pairs form Array Whose Sum is Equal to Given Number

Given an integer array and a number "sum", Print all the pairs of integers whose sum is equal to "sum".

For example: arr = [5,3,2,8,4,7] and sum = 7 So, thw output will be (5,2), (3,4)

This problem can be solved using the following method:

1. Native Method that uses nested for loops.


2. Using Hashmap or Dictionary


Thank you so much for reading this article, if you like this question please share this with your friends who love programming. And if you have questions or feedback please drop a comment.

To solve more problems please check out this article "Top 10 Array Interview Questions".

All the Best!

Comments

Popular posts from this blog

Four Sum Problem (4sum) Solution in Java, Python, C++

Find the length of the longest substring without repeating character

Reverse Words in a Sentence Without using any Library