PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Nextdoor

Implement and use a version comparator

Last updated: Mar 29, 2026

Quick Overview

This question evaluates string parsing, comparator design, sorting algorithm efficiency, and handling of semantic versioning semantics such as numeric versus non-numeric segments, missing segments, and pre-release ordering for large identifier lists.

  • Medium
  • Nextdoor
  • Coding & Algorithms
  • Machine Learning Engineer

Implement and use a version comparator

Company: Nextdoor

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given up to 100,000 version-like identifiers (e.g., "1.0", "01.2.0", "2.0.0-alpha", "1.10.3"). Implement compare(a, b) that orders identifiers by: ( 1) split by '.', compare numeric segments as integers; ( 2) missing segments are treated as 0; ( 3) pre-release tags (e.g., '-alpha', '-beta', '-rcN') sort before the corresponding release; numeric build metadata after a '+' is ignored for ordering. Use your comparator to return the list sorted in ascending order. Discuss time and space complexity and edge cases (leading zeros, different lengths, non-numeric segments). Provide code.

Quick Answer: This question evaluates string parsing, comparator design, sorting algorithm efficiency, and handling of semantic versioning semantics such as numeric versus non-numeric segments, missing segments, and pre-release ordering for large identifier lists.

Related Interview Questions

  • Group Photos and Sort Feed Items - Nextdoor (medium)
  • Simulate Transaction Lock Scheduling - Nextdoor (hard)
  • Build Ranked Feed With Photo Batching - Nextdoor (medium)
  • Merge Weekly Time Intervals - Nextdoor (medium)
  • Merge overlapping weekly time intervals - Nextdoor (medium)
Nextdoor logo
Nextdoor
Jul 27, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
6
0

You are given up to 100,000 version-like identifiers (e.g., "1.0", "01.2.0", "2.0.0-alpha", "1.10.3"). Implement compare(a, b) that orders identifiers by: (

  1. split by '.', compare numeric segments as integers; (
  2. missing segments are treated as 0; (
  3. pre-release tags (e.g., '-alpha', '-beta', '-rcN') sort before the corresponding release; numeric build metadata after a '+' is ignored for ordering. Use your comparator to return the list sorted in ascending order. Discuss time and space complexity and edge cases (leading zeros, different lengths, non-numeric segments). Provide code.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Nextdoor•More Machine Learning Engineer•Nextdoor Machine Learning Engineer•Nextdoor Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.