InterviewDB Experience

Ads Filter: Remove Advertisements from a List Based on Heuristics

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

  1. How would you extend the filter to use a blocklist of known ad sources?
  2. If type is missing or null, what fallback heuristic would you apply?
  3. How would you add a user-configurable filter pipeline where each rule is a pluggable strategy?
  4. 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

  1. How would you extend the filter to use a blocklist of known ad sources?
  2. If type is missing or null, what fallback heuristic would you apply?
  3. How would you add a user-configurable filter pipeline where each rule is a pluggable strategy?
  4. Extend to support "native ads" that look like articles — what signals would you use to detect them?

About This Question

This is a candidate experience report from a faire interview during the phone round.

It covers the following topics: Coding, Onsite, Phone .