You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classSolution:
defcompareVersion(self, version1: str, version2: str) ->int:
## preprocessing the data into lists1=version1.split('.')
s2=version2.split('.')
## Padding [0] and keep both of them with same lengthmax_len=max(len(s1),len(s2))
s1=self.zeroPadding(s1,max_len)
s2=self.zeroPadding(s2,max_len)
i=0## Compare versionwhilei<len(s1) andi<len(s2):
ifint(s1[i])==int(s2[i]):
i+=1elifint(s1[i]) >int(s2[i]):
return1else:
return-1return0defzeroPadding(self,s,max_len):
iflen(s) <max_len:
returns+ [0] * (max_len-len(s))
returns