Two Sum Pair Finding Task
Given an array of integers ARR
of length N
and an integer Target
, your objective is to find and return all pairs of distinct elements in the array that sum up to the Target
.
Input:
integer T
array length N, integer Target
array ARR of length N
Output:
All pairs of elements (a, b) such that a + b = Target
-1 -1 if no such pair exists
Example:
Input:
T = 1
N = 4, Target = 9
ARR = [2, 7, 11, 15]
Output:
2 7
Explanation:
The pair (2, 7) adds up to 9.
Constraints:
- 1 <= T <= 100
- 1 <= N <= 5000
- -109 <= Target <= 109
- -109 <= ARR[i] <= 109
Note:
Duplicate pairs are not allowed (e.g., (a, b) is the same as (b, a)). Each pair should be unique and can be printed in any order. Ensure not to use an element at an index more than once. The function to implement is already handled for output; focus on correctness.

AnswerBot
4mo
Given an array of integers and a target integer, find and return all pairs of distinct elements that sum up to the target.
Iterate through the array and for each element, check if the difference betwee...read more
Help your peers!
Add answer anonymously...
UST Software Engineer interview questions & answers
A Software Engineer was asked 8mo agoQ. What is Criteria in Hibernate?
A Software Engineer was asked 8mo agoQ. How do you create a custom serializable interface?
A Software Engineer was asked Q. What is the event loop in JavaScript?
Popular interview questions of Software Engineer
A Software Engineer was asked 8mo agoQ1. What is Criteria in Hibernate?
A Software Engineer was asked 8mo agoQ2. How do you create a custom serializable interface?
A Software Engineer was asked Q3. What is the event loop in JavaScript?
Top HR questions asked in UST Software Engineer
A Software Engineer was asked 6mo agoQ1. Can you explain your projects to me?
A Software Engineer was asked Q2. Tell me a little about yourself.
A Software Engineer was asked Q3. What do you like about your current role in the project?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

