Two software versions are given as dot-separated revision numbers, for example 1.2.10. Compare them numerically, one revision at a time from left to right: 1.2.10 is greater than 1.2.9 because 10 > 9. Leading zeros in a revision are ignored (1.01 equals 1.1). If one version has fewer revisions, treat the missing revisions as 0 (1.0 equals 1).
Line 1: the first version string v1.
Line 2: the second version string v2.
Print -1 if v1 < v2, 1 if v1 > v2, or 0 if they are equal.
Example 1
Input
1.2.10 1.2.9
Expected
1
Explanation
The first two revisions tie; in the third, 10 > 9, so v1 > v2 and the answer is 1.
Example 2
Input
1.0 1
Expected
0
Explanation
The missing revision of v2 is treated as 0, so 1.0 equals 1 and the answer is 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →