Python3 soln, xyz


#1

class Solution:
# @param A : string
# @param B : string
# @return an integer
def compareVersion(self, A, B):
A = A.split(’.’)
B = B.split(’.’)
i = 0
j = 0
na = len(A)
nb = len(B)
if na == 0 and nb != 0:
return -1
elif na != 0 and nb == 0:
return 1

	while i<na and j<nb:
		if int(A[i]) == int(B[j]):
			i+=1
			j+=1
		elif int(A[i]) > int(B[j]):
			return 1
		elif int(A[i]) < int(B[j]):
			return -1

	if i == na and j != nb:
		if B[j] == '0':
			return 0
		return -1
	elif i != na and j == nb:
		if A[i] == '0':
			return 0
		return 1
	return 0