zhukov000

Binary search example 2

Nov 13th, 2019
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. from bisect import bisect_left, bisect_right
  2.  
  3. n, k = map(int, input().split())
  4. a = [int(x) for x in input().split()]
  5.  
  6. for y in input().split():
  7.   y = int(y)
  8.  
  9.   if bisect_left(a, y) != bisect_right(a, y):
  10.     print("YES")
  11.   else:
  12.     print("NO")
Advertisement
Add Comment
Please, Sign In to add comment