Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,511 views

All past online assesments of Amazon can be found using the tag "amazon_oa" in the search bar.

Here is the link : https://www.desiqna.in/tag/amazon_oa

in Online Assessments by Expert (108,170 points)
edited by | 2,511 views

1 Answer

0 like 0 dislike

Write a function that takes a list of numbers and a target number, and then returns the number of unique pairs that add up to the target number.

[X, Y] and [Y, X] are considered the same pair, and not unique.

Examples

Example 1:

Input: [1, 1, 2, 45, 46, 46]target = 47

Output: 2

Explanation:

1 + 46 = 47

2 + 45 = 47

Example 2:

Input: [1, 1]target = 2

Output: 1

Explanation:

1 + 1 = 2

Example 3:

Input: [1, 5, 1, 5]target = 6

Output: 1

Explanation:

[1, 5] and [5, 1] are considered the same, therefore there is only one unique pair that adds up to 6.

by Expert (108,170 points)