Compare Dotted Version Strings for Windows Update Packages
Last updated: November 29, 2026
Quick Overview
Given two version strings such as "10.0.19045" and "10.0.19045.0", return -1, 0 or 1 depending on whether the first is lower, equal or higher, comparing numeric components left to right and treating missing components as zero.
Microsoft
November 29, 20260
0
0 solved
Given two version strings such as "10.0.19045" and "10.0.19045.0", return -1, 0 or 1 depending on whether the first is lower, equal or higher, comparing numeric components left to right and treating missing components as zero.
A typical Microsoft online assessment item framed around Windows Update deciding whether a package supersedes the installed build. The grader checks numeric rather than lexicographic comparison and correct handling of unequal lengths and leading zeros.
What the Interviewer Expects
- Compare components as integers, not strings
- Pad the shorter version with zeros
- Treat "1.01" and "1.001" as equal
- Return early at the first differing component
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you support pre-release tags like 1.2.0-beta.3?
- How would you sort a list of 100,000 versions efficiently?
- Can you do it without splitting, using two pointers?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each version is one or more non-negative integers separated by dots. Leading zeros are allowed and ignored. A missing trailing component counts as zero, so 10.0 equals 10.0.0. Return -1, 0 or 1. I...
High-Level Design
Split both strings into integer lists, then walk them in lockstep up to the longer length, substituting zero past the end of the shorter one. The first index where they differ decides the result. The ...