#-*- coding: UTF-8 -*-
class Solution(object):
def compareVersion(self, version1, version2):
"""
:type version1: str
:type version2: str
:rtype: int
"""
versionl1=version1.split('.')
versionl2=version2.split('.')
n1,n2=len(versionl1),len(versionl2)
if n1>n2:
versionl2+=[0]*(n1-n2)
else:versionl1+=[0]*(n2-n1)
for i in range(len(versionl1)):
if int(versionl1[i])>int(versionl2[i]):return 1
elif int(versionl1[i])<int(versionl2[i]):return -1
return 0
sol=Solution()
print sol.compareVersion('1', '1.1')
相关文章
- 03-20【leetcode❤python】 165. Compare Version Numbers
- 03-20LeetCode 165. Compare Version Numbers
- 03-20leetcode first bad version python
- 03-20【leetcode】Compare Version Numbers(middle)
- 03-20【leetcode 字符串处理】Compare Version Numbers
- 03-20【leetcode】Compare Version Numbers
- 03-20Compare Version Numbers leetcode
- 03-20【LeetCode】628. Maximum Product of Three Numbers 解题报告(Python)
- 03-20[LeetCode&Python] Problem 628. Maximum Product of Three Numbers
- 03-20[leetcode]Add Two Numbers @ Python