leetcode Plus One
2015-05-31 11:10
274 查看
基础题
题目链接这里
题目链接这里
public class Solution { public int[] plusOne(int[] digits) { int []result=digits; int jinwei=1; for(int i=result.length-1;i>=0;i--) { result[i]=jinwei+result[i]; jinwei=0; if(result[i]==10) { result[i]=0; jinwei=1; } } if(jinwei==0) { return result; } else { int []result1=new int[result.length+1]; System.arraycopy(result,0,result1,1,result.length); result1[0]=1; return result1; } } }
相关文章推荐
- hdu4339 Query
- PAT 1009 Product of Polynomials (25)多项式乘积
- AI初级模型
- 文件上传
- [转]看看国外的javascript题目,你能全部做对吗?
- 字典转模型需要注意的问题,以及第三方框架来处理字典转模型
- 使用Ajax验证用户名
- 游戏基本结构图
- Ubuntu 14.04 LNMP源码编译环境搭建 Nginx-1.9.1 PHP-5.6.9 Mariadb-10.0.19 完整教程
- maven学习-01
- Install: mysql-query-browser
- Skill: Add new mail attention extension in Thunderbird
- hdfs查看集群目录报javaIO异常
- Redis简介与安装
- CSS中内联/块级元素
- 仓库管理系统用例建模
- IIS FTP 出现 530 User cannot log in, home Directory Inaccessible 错误
- Android之Fragment使用简介
- VMware Workstation 共享虚拟机无法启用
- 网页元素居中攻略记_(3)已知宽高元素水平垂直居中