Hacker Earth Practice Problems - Discover the monk
Problem Statement:
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 nextQ lines contain a single integer X per line.
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 nextQ lines contain a single integer X per line.
Output:
For each query, print YES if the X is in the array, otherwise print NO.
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
1 <= N, Q <= 105
1 <= Ai <= 109
1 <= X <= 109
Time Limit: 1 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Solution:
a,b = map(int , raw_input().split())
k = raw_input()
L = map(int,k.split())
k = raw_input()
L = map(int,k.split())
while(b>0):
b-=1
if(input() in L):
print “YES”
else:
print “NO”
b-=1
if(input() in L):
print “YES”
else:
print “NO”
Comments
Post a Comment