All problems
Boolean AND Query
Problem
Return the sorted intersection of two posting lists, treating them as sets of document ids.
Duplicate postings are ignored, and disjoint lists yield an empty list.
Hint
Set membership handles duplicates and repeated ids at once.
Test cases
case 1
in: [[1,2,3],[2,3,4]]
expected: [2,3]
case 2
in: [[],[1]]
expected: []
case 3
in: [[1,2],[2,1]]
expected: [1,2]
case 4
in: [[5],[6]]
expected: []
Starter codePython
def boolean_and(postings1, postings2):
# Your code here
pass4 test cases · run your code against them in the editor