LintCode : 加一
来源:互联网 发布:饭卡充值软件 编辑:程序博客网 时间:2024/04/28 06:21
LintCode : 加一
给定一个非负数,表示一个数字数组,在该数的基础上+1,返回一个新的数组。
该数字按照大小进行排列,最大的数在列表的最前面。
先把数组组装成字符串,再把字符串转成数组,然后加1,再转成字符串,最后转成数组,有点麻烦。
public class Solution { /** * @param digits a number represented as an array of digits * @return the result */ public int[] plusOne(int[] digits) { // Write your code here String s = ""; for(int i=0; i<digits.length; i++){ s += digits[i]; } long m = Long.valueOf(s) + 1; String s1 = m + ""; int[] ans = new int[s1.length()]; for(int i=0; i<s1.length(); i++){ ans[i] = (Integer.valueOf(s1.charAt(i) + "")); } return ans; }}
0 0
- LintCode PlusOne 加一
- lintcode-加一-407
- LintCode : 加一
- 加一(LintCode)
- LintCode 407. 加一
- lintcode----加一
- 加一,lintcode
- LintCode 407-加一
- LintCode(加一)
- 【数组】[Lintcode]加一
- lintcode : 加一
- [LintCode]407.加一
- lintcode加一
- 加一 -LintCode
- [Lintcode] #407 加一
- 【Lintcode】加一
- lintcode 加一(Plus One )(Java)
- LintCode 第407题 加一
- handlebars的理解
- NOIP四校联训Round7小结
- uva327
- Mysql 事物介绍
- hdu 4620 Fruit Ninja Extreme(暴力)
- LintCode : 加一
- CC2640 SimpleBLEPeripheral 例程
- 记录——《C Primer Plus (第五版)》第九章编程练习第三题
- 超简单方法实现省/市/地区级联查询
- 面试100题004--二元树中找出和为某一值的所有路径
- 数据结构与算法学习笔记——二叉树重构(递归)
- F函数(水题)
- 控件拖拽
- hdu 4627 The Unsolvable Problem(暴力)