Leetcode66 python plus a __python

Source: Internet
Author: User

Given a non-empty array of nonnegative integers, add one on the basis of that number and return a new array.

The highest digits are stored first in the array, and each element in the array stores only one number.

You can assume that in addition to the integer 0, this integer does not start with 0.

Example 1:

Input: [1,2,3]
output: [1,2,4]
Explanation: The input array represents the number 123.

Example 2:

Input: [4,3,2,1]
output: [4,3,2,2]
Explanation: The input array represents the number 4321.

Python code

Class Solution:
    def plusone (self, digits): ""
        : Type Digits:list[int]
        : rtype:list[int]
        ""
        #数组转换成数字
        intnum=0 for
        i in range (len (digits)):
            intnum=intnum*10+digits[i]
        intnum+=1
        # Number converts to character
        Strnum=str (intnum)
        #字符转换成数组
        res=[] for
        i in range (len (strnum)):
            res.append (int ( Strnum[i]) return
        Res



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.