Skip to content
C

Keyword-Based FAQ Matcher

Mediumpython

Given a list of FAQ (question, answer) pairs and a user's question, find the FAQ answer whose question shares the most keywords with the user's question — a simple, non-embedding retrieval approach.

Approach: turn both the user's question and each FAQ question into a set of lowercased words, count the overlap, and return the answer for whichever FAQ has the highest overlap (first one wins on a tie).

Input: First line: the number of FAQs n. Next n lines: question|answer. Final line: the user's question.

Output: One line: the best-matching FAQ's answer.

Input (stdin)

Output

Run your code to see output here...