Skip to content

Commit

Permalink
Update Compare_Version_Numbers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
UmassJin committed Aug 11, 2015
1 parent 11ebd99 commit 8aaddbe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Array/Compare_Version_Numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

0.1 < 1.1 < 1.2 < 13.37

# https://leetcode.com/discuss/45331/2-4-lines-python-3-different-ways
def compareVersion(self, version1, version2):
v1, v2 = (map(int, v.split('.')) for v in (version1, version2))
d = len(v2) - len(v1)
return cmp(v1 + [0]*d, v2 + [0]*-d)


class Solution:
# @param version1, a string
# @param version2, a string
Expand Down

0 comments on commit 8aaddbe

Please sign in to comment.