Loading...
Loading...
Loading...
A gate has n valid ticket numbers. q visitors arrive. For each visitor print YES if their ticket number is valid, otherwise NO. Scanning the whole list for every visitor is too slow.
Example
Input
4 3 101 205 330 412 205 999 101
Output
YES NO YES
Try the problem first. Open one hint at a time.
A list in check scans the list, so q checks cost q × n.
Put the valid tickets in a set once, then every check is one lookup.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor