← Nextdoor Interview Insights

Nextdoor·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Coding round for a software engineer role at Nextdoor. One problem, feed grouping, which sounds straightforward until you actually sit down and think through the edge cases.

Questions Asked (1)

Q1

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

Algorithms & Data Structures
Author's notes

The grouping part clicked pretty fast but I fumbled on the score assignment for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, traverse the list to identify consecutive runs of Photo items and group every three into a PhotoGroup with the max score. Then, collect all ungrouped items and the new PhotoGroups, sort them by score descending, and return the result. Be sure to handle edge cases like leftover photos and maintain the original order within groups.

Pro tip: Clarify upfront whether the sort should be stable for ties and whether leftover photos (fewer than 3) should remain as individual items. This shows attention to detail and prevents incorrect assumptions.

1. Clarify requirements and edge cases

Ask about tie-breaking in sorting, handling of leftover photos (1 or 2), and whether grouping should reset after non-photo items. Confirm that the original order of photos within a group is preserved.

2. Design the grouping algorithm

Iterate through the list, maintaining a buffer of consecutive photos. When the buffer reaches 3, create a PhotoGroup with the max score, clear the buffer, and continue. At the end, any remaining photos in the buffer are treated as individual items.

3. Collect and sort items

Gather all non-photo items, leftover photos, and newly created PhotoGroups into a single list. Sort this list by score in descending order, using a stable sort if tie-breaking is unspecified.

4. Analyze complexity and optimize

Discuss time and space complexity: O(n) for grouping and O(n log n) for sorting, where n is the number of items. Mention that the grouping can be done in a single pass and sorting is the dominant cost.

5. Test with examples

Walk through a concrete example, such as a list with mixed types and multiple photo runs, to verify the grouping and sorting logic. Include edge cases like no photos, exactly 3 photos, and photos at the end.

Key Points to Mention

  • Single-pass grouping of consecutive photos using a buffer or counter
  • Creating a new PhotoGroup object with max score and preserving original order
  • Handling leftover photos (1 or 2) as individual items
  • Sorting by score descending with stable sort for ties
  • Time complexity: O(n log n) due to sorting, space complexity: O(n)
  • Edge cases: no photos, photos separated by other types, all photos

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