Compare Version Numbers
Explore how to compare version strings by analyzing each revision as integers using two pointers. This lesson helps you understand how to handle missing revisions and correctly determine version order, preparing you for related coding interview questions.
We'll cover the following...
We'll cover the following...
Statement
Given two version strings, version1 and version2, compare them. A version string is composed of revisions separated by dots ('.'). Each revision’s value is determined by converting it to an integer, disregarding any leading zeros.
Compare the two version strings by evaluating their revision values from left to right. If one version string contains fewer revisions than the other, treat each missing revision as 0.
Return the result of the comparison as follows:
Return
...