Z59
Inverted Index & Boolean Search Engine
Problem Statement & Objective
Build an in-memory inverted index supporting AND, OR, NOT search queries over a document collection.
Function Signature (Python)
inverted_index_boolean_search_engine(documents: list[str], queries: list) -> list[list[int]]Input & Output Contract
Output Rule:Her sorgu için sıralı doküman indeksleri listesi.
System Constraints
1 <= dokumanlar.length <= 1000
1 <= sorgular.length <= 500
Kelimeler küçük/büyük harf ve rakamlardan oluşurExample Execution Walkthrough
dokumanlar = ['Python ile veri yapilari', 'Veri bilimi ve yapay zeka', 'Python yapay zeka kodlari']
sorgu 1: ['AND', 'python', 'yapay'] -> doc 2
sorgu 2: ['OR', 'veri', 'kodlari'] -> doc 0, doc 1, doc 2
Cevap: [[2], [0, 1, 2]]Example Test Scenarios (3)
Example 1: Temel Boolean Arama
Input:
[["Python ile veri yapilari","Veri bilimi ve yapay zeka","Python yapay zeka kodlari"],[["AND","python","yapay"],["OR","veri","kodlari"]]]Expected Output:
[[2],[0,1,2]]Example 2: Harf Dokümanları
Input:
[["a b c","b c d","c d e"],[["AND","b","d"],["OR","a","e"]]]Expected Output:
[[1],[0,2]]Example 3: Bulunamayan Kelime
Input:
[["hello world"],[["AND","missing"]]]Expected Output:
[[]]