Code RoomTest train data leakage
EasyPrep Room Coding #540

Test train data leakage

CodingML systemsAlgorithms & data structuresEntry–Mid~10 min

A suspiciously high eval score often means test data leaked into training. Given train and test, two lists of example strings (chat messages used to train and evaluate a moderation model), return how many entries of test also appear anywhere in train, using exact string comparison. Count each test entry every time it occurs in the test list, but at most once per occurrence regardless of how many times it appears in train. Example: train = ["buy now", "hello team"], test = ["hello team", "lunch?", "hello team"] returns 2.

Implement
leakage_count(train: list[str], test: list[str]) → int
Examples
in[["buy now","hello team"],["hello team","lunch?","hello team"]]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 10 min
InputExpectedGot
[["buy now","hello team"],["hello team","lunch?","hello team"]]2not run yetsample