AC Python code without extending the list

  • 0

    Python solution without extending one of the two numbers

    class Solution:
    def compareVersion(self, version1, version2):
        for i in range(max(len(v1),len(v2))):
            v1p=v1[i] if i <len(v1) else 0
            v2p=v2[i] if i <len(v2) else 0
            if v1p>v2p:
                return 1
            elif v2p>v1p:
                return -1
        return 0

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.