← Nextdoor Interview Insights

Nextdoor·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Coding round for a software engineer role at Nextdoor. One problem, feed grouping, which sounds straightforward until you start thinking about edge cases with the ordering logic.

Questions Asked (1)

Q1

You're given a list of feed items (Normal, Video, Photo), each with an id, type, and score. Group every 3 consecutive Photos into a PhotoGroup (preserving their original order), where the group's score is the max score of its members. Then sort all items (including ungrouped ones) by score descending.

Algorithms & Data StructuresData Modeling
Author's notes

The grouping part clicked pretty fast but I tripped on the score calculation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the grouping rule: only consecutive Photos are grouped in chunks of exactly 3, and any leftover Photos (1 or 2) remain ungrouped. Then, implement a single pass to build the output list by scanning the input, grouping every 3 consecutive Photos into a PhotoGroup with max score, and finally sort the resulting list by score descending.

Pro tip: Mention that you would preserve the relative order of items with equal scores by using a stable sort, and discuss the trade-off between in-place grouping and creating a new list for clarity and immutability.

1. Clarify requirements and edge cases

Confirm that grouping applies only to consecutive Photos, groups are exactly 3, and leftover Photos remain ungrouped. Ask about tie-breaking in sorting and whether the original list can be mutated.

2. Design the grouping algorithm

Plan a single pass through the list, maintaining a buffer of consecutive Photos. When the buffer reaches 3, create a PhotoGroup with max score and reset the buffer.

3. Handle ungrouped items and leftovers

After the pass, any remaining Photos in the buffer (1 or 2) are added as individual items. All non-Photo items are added as-is.

4. Sort the combined list

Sort all items (groups and ungrouped) by score descending. Use a stable sort to preserve original order for equal scores.

5. Analyze complexity and test

State time complexity O(n log n) due to sorting, space O(n). Walk through examples including edge cases like no Photos, exactly 3 Photos, and multiple groups.

Key Points to Mention

  • Consecutive grouping: only adjacent Photos are grouped; non-Photo items break the sequence.
  • Group size exactly 3: leftover Photos (1 or 2) remain ungrouped.
  • Group score is the maximum of member scores.
  • Stable sorting to preserve original order for equal scores.
  • Time complexity: O(n log n) due to sorting; space complexity: O(n).
  • Edge cases: empty list, all Photos, no Photos, multiple groups, and ties in scores.

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