LeetCode 66. Plus One(加1)
来源:互联网 发布:企业网站排名怎么优化 编辑:程序博客网 时间:2024/05/21 09:28
原题网址:https://leetcode.com/problems/plus-one/
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
方法:按照运算规则。
public class Solution { public int[] plusOne(int[] digits) { int carry = 0; digits[digits.length-1] += 1; for(int i=digits.length-1; i>=0; i--) { digits[i] += carry; carry = digits[i] / 10; digits[i] %= 10; } if (carry == 0) return digits; int[] result = new int[digits.length+1]; result[0] = carry; for(int i=0; i<digits.length; i++) { result[i+1] = digits[i]; } return result; }}
0 0
- LeetCode 66. Plus One(加1)
- LeetCode--Plus one(加1)Python
- leetcode 66. Plus One-加一
- leetcode 66. Plus One加一
- LeetCode | Plus One(数组表示的数字加1)
- Leetcode刷题记—— 66. Plus One(加1)
- (LeetCode)Plus One --- 加一
- leetcode Plus One 加一
- Leetcode 66. Plus One 加一! 解题报告
- LeetCode-66:Plus One (数组看作数据 加1)
- LeetCode 66 Plus One(加一)(vector)
- leetcode:Plus One (加一)【面试算法题】
- LeetCode OJ 之 Plus One (加一)
- [LeetCode]66.Plus One
- LeetCode --- 66. Plus One
- [Leetcode] 66. Plus One
- [leetcode] 66.Plus One
- [leetcode] 66. Plus One
- 老天待我不薄,又来这么一题POJ1753
- 网络黑客攻防学习平台之基础关第九题
- 法国INRIA Data Sets & Images 数据集和图像库
- 725 - Division
- XE7开发APK
- LeetCode 66. Plus One(加1)
- 如何踏上前端之路(干货高能预警)
- The BioID Face Database 人脸数据集
- POJ 3342 Party at Hali-Bula【树型dp好题】
- android启动模式简介
- 损失函数(Loss Function)
- 第十三周项目二 阅读修改关于交通工具类的程序,回答问题,以理解相关内容(3)
- block 实现原理(内存管理详解)(二)
- 动态规划——hdoj 1087解题报告