InterviewDB
Experience
Ads Filter: Remove Advertisements from a List Based on Heuristics
phone
Interview Experience
Problem
You are given a list of content items, each with a type ("article", "ad", "sponsored"), source, and score. Filter out items that are ads or sponsored, and also remove organic items with a score below a minimum threshold.
Return the remaining items sorted by score descending.
python
from dataclasses import dataclass
@dataclass
class ContentItem:
id: int
type: str
source: str
score: float
def filter_ads(
items: list[ContentItem],
min_score: float
) -> list[ContentItem]:
pass
**Input**:
items = [
ContentItem(1, "article", "cnn", 0.9),
ContentItem(2, "ad", "google", 0.95),
ContentItem(3, "sponsored", "brand", 0.7),
ContentItem(4, "article", "bbc", 0.3),
]
min_score = 0.5
Output: [ContentItem(1, "article", "cnn", 0.9)]
# item 2,3 removed (ad/sponsored), item 4 below threshold
Follow-ups
- How would you extend the filter to use a blocklist of known ad sources?
- If
typeis missing or null, what fallback heuristic would you apply? - How would you add a user-configurable filter pipeline where each rule is a pluggable strategy?
- Extend to support "native ads" that look like articles — what signals would you use to detect them?
Full Details
Problem
You are given a list of content items, each with a type ("article", "ad", "sponsored"), source, and score. Filter out items that are ads or sponsored, and also remove organic items with a score below a minimum threshold.
Return the remaining items sorted by score descending.
python
from dataclasses import dataclass
@dataclass
class ContentItem:
id: int
type: str
source: str
score: float
def filter_ads(
items: list[ContentItem],
min_score: float
) -> list[ContentItem]:
pass
**Input**:
items = [
ContentItem(1, "article", "cnn", 0.9),
ContentItem(2, "ad", "google", 0.95),
ContentItem(3, "sponsored", "brand", 0.7),
ContentItem(4, "article", "bbc", 0.3),
]
min_score = 0.5
Output: [ContentItem(1, "article", "cnn", 0.9)]
# item 2,3 removed (ad/sponsored), item 4 below threshold
Follow-ups
- How would you extend the filter to use a blocklist of known ad sources?
- If
typeis missing or null, what fallback heuristic would you apply? - How would you add a user-configurable filter pipeline where each rule is a pluggable strategy?
- Extend to support "native ads" that look like articles — what signals would you use to detect them?
Free preview. Unlock all Faire questions →
About This Question
This is a candidate experience report from a faire interview during the phone round.
More Faire Interview Questions
InterviewDB
Date Format: Parse and Normalize Dates Across Multiple Input Formats
InterviewDB
Faire SWE Phone - Zero Matrix (Matrix/In-place)
InterviewDB
Funnel Count: Compute Drop-Off at Each Step of a Conversion Funnel
InterviewDB
Haiku Substring: Find Substrings Matching a 5-7-5 Syllable Pattern
InterviewDB
Split SMS: Break a Long Message into Valid SMS Segments