One Liner in Python


  • 0
    O
    class Solution:
    # @param digits, a list of integer digits
    # @return a list of integer digits
    def plusOne(self, digits):
        return [ int(n) for n in str(int("".join([str(d) for d in digits])) + 1)]

  • 0
    O

    @odieatla
    Exactly the same idea.
    class Solution(object):
    def plusOne(self, digits):
    """
    :type digits: List[int]
    :rtype: List[int]
    """
    return [int(char) for char in str(int(''.join([str(digit) for digit in digits]))+1)]


Log in to reply
 

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