Leetcode_Plus One
来源:互联网 发布:iphone6s屏幕解锁软件 编辑:程序博客网 时间:2024/06/06 06:54
Tag
Array\Math
Difficulty
Easy
Description
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.
Code
用一个FLAG来判断是否有进位
class Solution(object): def plusOne(self, digits): digits.reverse() flag=1 for i in range(len(digits)): if digits[i]+flag<10: digits[i]+=flag flag=0 else: digits[i]=0 flag=1 if flag==1: digits.append(1) digits.reverse() return digits
0 0
- LeetCode_Plus One
- LeetCode_Plus One
- leetcode_Plus One
- LeetCode_plus-one
- Leetcode_Plus One
- Leetcode_plus-one(c++ and python updated)
- One
- one
- one:
- One
- ONE
- one
- one
- one
- one
- one
- one
- One!
- 安卓使用VideoView播放raw目录的视频和sd卡的视频
- WiKitude6.0中文教程
- 实现自定义checkbox、radio样式
- android studio 总结自己开发中常常用到的快捷键
- Java Jvm运行机制原理
- Leetcode_Plus One
- Node.js中的Buffer对象
- cf#402 E 大模拟
- Visual Studio 各版本下载
- node-webkit制作桌面应用
- uboot的源码目录分析
- c# 托盘程序编程
- struts2中的jar包简述
- Java学习:java面试