Description
Compare two version numbers version1 and version2. Return -1 if v1 < v2, 1 if v1 > v2, and 0 if equal.
Examples
Input:
version1 = "1.01", version2 = "1.001"Output:
0Explanation:
Leading zeros are ignored, both are 1.1.
Input:
version1 = "1.0", version2 = "1.0.0"Output:
0Explanation:
Edge case returning zero.
Input:
version1 = "2.1", version2 = "2.0.1"Output:
1Explanation:
After splitting by dots: v1 = [2, 1] and v2 = [2, 0, 1]. First part: 2 = 2. Second part: 1 > 0, so v1 > v2.
Constraints
- •
1 ≤ version1.length, version2.length ≤ 500