Given two version strings version1 and version2, made of revisions separated by dots, compare them revision by revision from left to right. Each revision is compared as an integer, so leading zeros are ignored, and a missing revision counts as 0. Return -1 if version1 < version2, 1 if version1 > version2, and 0 otherwise.
Given two version strings version1 and version2, made of revisions separated by dots, compare them revision by revision from left to right. Each revision is compared as an integer, so leading zeros are ignored, and a missing revision counts as 0. Return -1 if version1 < version2, 1 if version1 > version2, and 0 otherwise.
Example 1:
Input: {"version1":"1.2","version2":"1.10"}
Output: -1
Constraints:
1≤version1.length,version2.length≤500
version1 and version2 only contain digits and '.'.
version1 and version2 are valid version numbers.
All the given revisions in version1 and version2 can be stored in a 32-bit integer.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"version1":"1.2","version2":"1.10"}
Put i at the start of version1 and j at the start of version2. Revision 1 is read first.