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
Post a Comment