I need to check if the items in one list are in another list. Both lists contain paths to files.
list1 = [a/b/c/file1.txt, b/c/d/file2.txt]
list2 = [a/b/c/file1.txt, b/c/d/file2.txt, d/f/g/test4.txt, d/k/test5.txt]
I tried something like:
len1 = len(list1)
len2 = len(list2)
res = list(set(list2) - set(list1))
len3 = len(res)
if len2 - len1 == len3:
print("List2 contains all the items in list1")
But it's not an optimal option, I have lists of 50k+ items. I think a good solution can be by creating a hash table, but I don't know exactly how I could build it. If you have any suggestions you can leave a message.