天天看點

時間上相鄰query,字首去重

1、時間上相鄰query,字首去重

輸入:[(AB, 2019-12-25 12:11:23), (A, 2019-12-25 12:11:22), (ABC, 2019-12-25

12:11:22), (BCD, 2019-12-25 12:11:30), (B, 2019-12-25 12:11:31)]

輸出:[ (ABC, 2019-12-25 12:11:22), (BCD, 2019-12-25 12:11:30), (B, 2019-12-25

12:11:31)]

l2=[]

ll2=[]

ll3 =[]

for i in li:

l2.append(i[1])

ll2=set(l2)

if ll2 not in li:

ll3.append(li.pop())

print(ll3)