D21-读论文D21&算法D21

840模拟散列表

N, null = 200003, 0x3f3f3f3f
s = [null]*N

def find(x):
    k = x%N
    while s[k]!=null and s[k]!=x:
        k += 1
        if k==N:
            k = 0
    return k

n = int(input())

for _ in range(n):
    op, pt = input().split()
    x = int(pt)
    if op=='I':
        s[find(x)] = x
    else:
        if s[find(x)] == x:
            print('Yes')
        else:
            print('No')

你可能感兴趣的:(python,每日一题,算法)