Created
November 27, 2018 02:56
-
-
Save farsialgorithm/e6c32cd1a3c2f1e5d16f5b883ffe8d64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def compareVersion(version1, version2): | |
| p1 = map(int, version1.split(".")) | |
| p2 = map(int, version2.split(".")) | |
| d = len(p1)-len(p2) | |
| p1 += [0] * (-d) | |
| p2 += [0] * (d) | |
| for i in range(len(p1)): | |
| if p1[i] > p2[i]: | |
| return 1 | |
| if p1[i] < p2[i]: | |
| return -1 | |
| return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment