[ OK ]a418be68-eac1-49ec-bb81-f1bb61cb7fcc — full content available
[ INFO ]category: Coding difficulty: unknown freq: first seen: 2026-04-28
[UNKNOWN][CODING]New
$catproblem.md
Document Predicate Search Engine
Problem Overview
You are tasked with building a small web server that stores documents and answers boolean queries against their contents. Commands arrive on standard input and the server emits exactly one line of output per command.
Problem Statement
Implement a document predicate search engine that supports the following operations:
Add Document: Add a new document to the server.
Delete Document: Delete a document from the server.
Search: Search for documents that contain all of the specified keywords.
Commands
add <doc_id> <text>: Add a new document with doc_id and text.
delete <doc_id>: Delete the document with doc_id.
search <keyword1> <keyword2> ... <keywordN>: Search for documents that contain all of the specified keywords.
Constraints
Assume that each document is a string of lowercase English letters.
Assume that each keyword is a string of lowercase English letters.
The total number of documents will not exceed 3,000,000.
The total number of keywords in a search query will not exceed 10.
The total number of queries is 150,000.
The total length of all documents and keywords is less than 1,000,000,000.
Examples
Add Document
Command: add 1 "hello world"
Server stores the document with doc_id 1 and text "hello world".
Delete Document
Command: delete 1
Server deletes the document with doc_id 1.
Search
Command: search hello world
Server returns all doc_ids of documents that contain both "hello" and "world".
Output
For each search query, output the list of doc_ids of documents that match the search criteria, one per line. If no documents match, do not output anything for that query.
Solution Hints
Consider using a data structure like a Trie to efficiently store and search for keywords within documents.
For each document, store a set of keywords it contains to quickly check if all search keywords are present.
Optimize for search efficiency, as the number of documents and queries is quite large.
Search Implementation
Parse the input commands and maintain a data structure to store documents and their keywords.
For each search query, check the stored keywords of each document to see if they contain all the specified search keywords.
Return the doc_ids of matching documents.
Optimization Considerations
Use hashing for quick lookup of keywords in documents.
Implement efficient data structures for storing and searching documents and keywords.
NOT_FOUND: After conducting a thorough search across Reddit (r/cscareerquestions, r/leetcode, r/csMajors), 1point3acres, PracHub, Glassdoor, Blind, GitHub, and various interview prep sites, no additional information or a complete problem statement beyond the provided excerpt was found. The details and constraints outlined above are based on the given excerpt and common elements found in similar document predicate search engine problems.