One liner Python solution that is actually not a very good or clear solution

  • 1
    def plusOne(self, digits):
            return list(int(j) for j in str(int(''.join(str(i) for i in digits))+1))

    I'm aware this is not a very clear or good solution, but I just wanted to see if I could do it in one line. You basically turn the original list to an int, add 1, and turn it back into a list.

  • 0

    Same answer using 3 lines, so yours is better. But I also don't think it is the 'right' way to solve it.

Log in to reply

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