Sum of Two Numbers
InterviewTime limit1sMemory limit128 MB
Count pairs of distinct integers in an array that sum exactly to a given value x.
- Level
Easy3 of 10
- Topics
- Hash map, Two pointers, Array
- Solved
- No attempts yet
Problem
You are given a sequence of distinct positive integers , where each is a natural number with .
Given a natural number , write a program that counts the number of pairs with such that .
Input
The first line contains the size of the sequence, .
The second line contains the distinct natural numbers of the sequence, separated by spaces.
The third line contains the natural number .
, ,
Output
Print the number of pairs that satisfy the condition on a single line.