← 返回 amazon 的题目列表Count Unique Pairs with Sum Equal to Target
类型:online_judge
amazon
Given an integer array array and an integer target, calculate the number of unique pairs that sum to target. Note that a pair is considered as a set, so the order does not matter. For example, if array is [1,2,1] and target is 3, the valid pair is (1,2), so the result is 1.
Input
array: An integer array.
target: An integer.
Output
Return the number of unique pairs that sum to target.
Example
array = [1, 2, 1]
target = 3
Output: 1
Constraints
Array length does not exceed 10^4.
Absolute values of array elements do not exceed 10^4.
Absolute values of target do not exceed 10^5.
Example
Input
1
3
0