classSolution: defcompareVersion(self, version1: str, version2: str) -> int: v1 = version1.split('.') v2 = version2.split('.') length1 = len(v1) length2 = len(v2) for i in range(min(length1, length2)): if int(v1[i]) < int(v2[i]): return-1 elif int(v1[i]) > int(v2[i]): return1 if length1 > length2: for i in range(length2, length1): if int(v1[i]) > 0: return1 else: for i in range(length1, length2): if int(v2[i]) > 0: return-1 return0