← Nextdoor Interview Insights

Nextdoor·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

Coding round for an ML Engineer role at Nextdoor. The problem was a feed construction question that felt more like a backend/data engineering puzzle than anything ML-specific, which threw me a bit.

Questions Asked (1)

Q1

Given a list of feed objects each with an id, type (Normal, Video, or Photo), and a numeric score, implement a function that constructs a final ranked feed by sorting objects by score descending, grouping consecutive Photos into batches of up to 3, treating each batch as a single feed item scored by its first photo, then merging everything back into a final descending-score order.

Algorithms & Data StructuresSystem Design
Author's notes

The sorting part was fine, stable sort by score and move on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the requirements and edge cases, then outline a two-phase algorithm: sort by score descending, then scan to group consecutive photos into batches of up to 3, and finally re-sort the merged items by their representative scores. Discuss time/space complexity and potential optimizations, and relate the problem to real-world feed ranking at Nextdoor.

Pro tip: Emphasize that the grouping must be done on the already sorted list to ensure consecutive photos are batched, and that the batch's score is the first photo's score—this preserves the relative order when re-sorting. Also, mention that stable sorting or a tie-breaking rule may be needed for equal scores.

1. Clarify requirements and edge cases

Ask about input size, score ties, empty lists, and whether photos can be grouped across non-photo items. Confirm that batches are formed only from consecutive photos in the sorted list.

2. Design the algorithm

Sort the feed by score descending. Then iterate through the sorted list, grouping consecutive photos into batches of up to 3. Each batch becomes a single item with score equal to the first photo's score.

3. Merge and re-sort

Collect all non-photo items and photo batches into a new list, then sort this list by score descending. Ensure that the original order of items with equal scores is preserved if needed.

4. Analyze complexity and optimize

Discuss time complexity: O(n log n) due to sorting. Space complexity: O(n). Consider if a single pass with a priority queue could work, but note that grouping requires sorted order.

5. Test with examples

Walk through a small example to verify correctness, including edge cases like all photos, no photos, and ties in scores.

Key Points to Mention

  • Sorting stability and tie-breaking rules for equal scores
  • Consecutive grouping definition: only adjacent photos in the sorted list are batched
  • Batch score is determined by the first photo's score, not an average or max
  • Time and space complexity analysis (O(n log n) time, O(n) space)
  • Edge cases: empty input, single item, all photos, photos with same score
  • Potential real-world application: feed ranking at Nextdoor and how this algorithm might scale

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.