Python one line solution


  • 0
    F
    class Solution:
    # @param {integer[]} digits
    # @return {integer[]}
    def plusOne(self, digits):
    return [int(x) for x in str(int(''.join("%s" % el for el in digits))+1)]

  • 0
    E

    Yep, I come out the similar solution.

    return [int(c) for c in str(int(''.join([str(i) for i in digits])) + 1)]

    But I would like to know if there is any limitation for this way. Thanks.


Log in to reply
 

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