Reddit Machine Learning Engineer Interview Experience — Onsite with a Cat/Dog Comment-Tree Filter and a Comment-Likelihood ML Design

Reddit·Machine Learning Engineer·Sep 2026
Onsitemedium

Coding: seems like a new question? I had AI rewrite it:

You are given a dictionary of Reddit comments.

Each comment contains:

  • id
  • parent_comment
  • body
  • cat: whether the comment is about cats
  • dog: whether the comment is about dogs

Example input:

comments = {
    0: {"id": 0, "parent_comment": None, "body": "Look! A cute baby elephant taking a nap!", "cat": False, "dog": False},
    2: {"id": 2, "parent_comment": 1, "body": "I agree!", "cat": False, "dog": False},
    11: {"id": 11, "parent_comment": 0, "body": "Almost as cute as my poodle!", "cat": False, "dog": True},
}

Comments form a tree using parent_comment.

There are two user modes:

  • CAT_PERSON: does not want to see dog-related comments
  • DOG_PERSON: does not want to see cat-related comments

Rule: If a comment is about an undesired animal, exclude that comment AND all of its child/descendant comments.

Write a function:

def get_comments_to_exclude(comments, mode): ...

Return a set of comment IDs that should be excluded.

Example: if comment 5 is about dogs and the tree is:

5
└── 6
    └── 7
        └── 8

then for CAT_PERSON, return:

{5, 6, 7, 8}

Follow-up: What are the time and space complexities?

ML SD: comment likelihood, a question that's already been posted on the forum. They focused very heavily on feature serving and model serving.

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
Reddit
Role
Machine Learning Engineer
Rounds
Onsite
Difficulty
medium
Interview date
Sep 2026
Questions from this interview
2 questions

Real Reddit interview experiences

First-hand reports from Reddit candidates — the rounds, the questions they were asked, and how it went.

All 9 Reddit interview experiences