Python - Simple one line soluton

  • 0
    class Solution(object):
    	def plusOne(self, digits):
    		:type digits: List[int]
    		:rtype: List[int]
    		return [int(i) for i in str(int(''.join([str(digit) for digit in digits]))+1)]
    1. Make list of strings
    2. Join them
    3. convert to int
    4. Add one
    5. Convert to string
    6. Return list comprehensions

Log in to reply

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