Discover the Monk
Practice
3.5 (272 votes)
Binary search
Easy
Open
Sorting
Problem
89% Success 32560 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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 Ai. The next Q 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 <= 105
1 <= Ai <= 109
1 <= X <= 109

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
13 votes
Tags:
AlgorithmsBinary SearchEasySearchingsearching
Points:20
17 votes
Tags:
AlgorithmsBinary SearchEasySearching
Points:20
200 votes
Tags:
ApprovedBinary SearchEasyOpenSorting