标签:
用python处理字符串还是比较简单的
class Solution: # @param {string} version1 # @param {string} version2 # @return {integer} def compareVersion(self, version1, version2): v1 = [int(v) for v in version1.split(".")] v2 = [int(v) for v in version2.split(".")] v1 += [0] * (len(v2) - len(v1)) v2 += [0] * (len(v1) - len(v2)) return 1 if v1 > v2 else (-1 if v1 < v2 else 0)
标签:
原文地址:http://www.cnblogs.com/dapanshe/p/4663872.html