Given two version strings version1 and version2, compare them.
Version strings consist of one or more numeric parts separated by dots '.'. Each part is a non-negative integer.
Compare the parts left to right. If one version has fewer parts, treat the missing parts as 0.
Return:
-1 if version1 < version21 if version1 > version20 if they are equalFor example, "1.0" and "1" are equal because the missing part in "1" is treated as 0.
version1 = "1.2.3", version2 = "1.2.4"-1version1 = "1.0", version2 = "1"0version1 = "2.0.1", version2 = "2.0.0"11 <= version1.length, version2.length <= 100Version strings consist of digits and dots only.Each numeric part is a valid non-negative integer (no leading zeros issues for comparison — treat as integers).Run your code to see results
Use Cmd+Enter to run