66. Plus One Python


  • 0
    O
    def plusOne(self, digits):
            """
            :type digits: List[int]
            :rtype: List[int]
            """
            first_el = digits[0]
            n = len(digits)
            if n > 1 or first_el+1 == 10:
                n_str = int(''.join(map(str, digits))) + 1
                return map(int, str(n_str))
            else:
                digits[0] += 1
            return digits
    

Log in to reply
 

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