专栏首页Petrichor的专栏leetcode: 66. Plus One

leetcode: 66. Plus One

Problem

# Given a non-negative integer represented as a non-empty array of digits, 
# plus one to the integer.
#
# You may assume the integer do not contain any leading zero, except the number 0 itself.
#
# The digits are stored such that the most significant digit is at the head of the list.

AC

class Solution():
    def plusOne(self, x):
        x = [str(x) for x in x]
        num = int(''.join(x)) + 1
        return [int(x) for x in str(num)]


if __name__ == "__main__":
    assert Solution().plusOne([9, 9, 9, 9]) == [1, 0, 0, 0, 0]

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • nano:基本操作

    JNingWei
  • leetcode: 53. Maximum Subarray

    JNingWei
  • leetcode: 119. Pascal's Triangle II

    JNingWei
  • Tour UVA - 1347

    John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small...

    attack
  • 如何在SAP C4C AdvancedListPane上批量执行若干BO实例的action

    Recently one partner asked me about this question. Suppose I have a custom BO wi...

    Jerry Wang
  • Neurons字幕组 | 2分钟带你了解如何把人类表情迁移到大猩猩上

    大数据文摘
  • 聊聊flink的RichParallelSourceFunction

    flink-streaming-java_2.11-1.6.2-sources.jar!/org/apache/flink/streaming/api/func...

    codecraft
  • 聊聊flink的RichParallelSourceFunction

    flink-streaming-java_2.11-1.6.2-sources.jar!/org/apache/flink/streaming/api/func...

    codecraft
  • SAP ABAP 使用内存参数设置SET /GET PARAMTER ID

    SET /GET PARAMTER ID使用SPA/GPA 参数--SAP内存参数设置

    matinal
  • Redis 为什么这么快?(9)

    因为单线程已经够用了,CPU不是redis的瓶颈。Redis的瓶颈最有可能是机器内存或者网络带宽。既然单线程容易实现,而且CPU不会成为瓶颈,那就顺理成章地采用...

    兜兜毛毛

扫码关注云+社区

领取腾讯云代金券