Compare Two Kindle Firmware Version Strings Segment by Segment

Last updated: November 29, 2026

Quick Overview

Given two dotted version strings such as `5.16.2` and `5.16.2.0.1`, return -1, 0, or 1 depending on whether the first is older, equal, or newer. Missing segments count as 0 and leading zeros are ignored.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given two dotted version strings such as `5.16.2` and `5.16.2.0.1`, return -1, 0, or 1 depending on whether the first is older, equal, or newer. Missing segments count as 0 and leading zeros are ignored.

An online assessment style question tied to over-the-air updates for devices like Kindle and Echo, where the fleet service must decide whether a device needs a new build. It checks careful numeric comparison rather than lexicographic string comparison.

What the Interviewer Expects
  • Compares numerically, not lexicographically
  • Pads the shorter version with zeros
  • Ignores leading zeros like 01
  • Stops at the first differing segment
  • Avoids building large intermediate lists when asked
Key Topics to Cover
string parsing
two pointers
comparison
versioning
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you add pre-release tags like 5.16.2-beta.3?
  • Can you do it in O(1) extra space with two pointers?
  • How would you sort a list of 100k versions efficiently?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs are non-empty strings of digits and dots. Compare segment by segment as integers; absent trailing segments are 0. Return -1, 0, 1....

High-Level Design

The trap is string comparison: '10' < '9' lexicographically, which would tell a device on 5.16.10 to downgrade to 5.16.9. The simple approach splits on dots, converts to int, and pads with zeros. A ...


Submit Your Answer
Markdown supported