Computer Science, asked by learner911, 5 months ago

You are given an array A of size N, and Q queries to deal with. For each query, you are
given an integer X, and you're supposed to find out if X is present in the array A or not.
Input:
The first line contains two integers, N and Q, denoting the size of array A and number of
queries. The second line contains N space separated integers, denoting the array of
elements Aj. The next lines contain a single integer X per line.
Output:
For each query, print YES if the X is in the array, otherwise print No.
Constraints:
1 <= N,Q = 10^5
1 <= Ai= 10^9
1 <=x <= 10​^9

Answers

Answered by kanishkarb3
0

Explanation:

The first line contains two integers, N and Q, denoting the size of array A and number of

queries. The second line contains N space separated integers, denoting the array of

elements Ai. The next Q lines contain a single integer X per line.

Answered by dipanjaltaw35
0

Answer:

Write a programme that checks whether there are two elements in S whose sum is exactly x given an array A[] of n numbers and another number x.

Examples:

Input: arr[] = {0, -1, 2, -3, 1}

sum = -2

Output: -3, 1

If we calculate the sum of the output,

1 + (-3) = -2

Input: arr[] = {1, -2, 1, 0, 5}

sum = 0

Output: -1

No valid pair exists.

Explanation:

The study of computation, automation, and information is known as computer science. Algorithms, computation theory, information theory, and automation are examples of theoretical disciplines in computer science (including the design and implementation of hardware and software). Computer science is typically thought of as a field of study that is separate from computer programming.

Data structures and algorithms are essential to computer science. The theory of computation focuses on generic classes of problems that can be solved using abstract models of computation. The study of methods for secure communication and for avoiding security flaws is a focus of the fields of cryptography and computer security. The creation of images is addressed by computational geometry and computer graphics.

For more similar questions refer to-

https://brainly.in/question/28127453

https://brainly.in/question/28195415

#SPJ3

Similar questions