[算法相关] LeetCode_66. Plus One_数组加一

66. 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 len = digits.length;
        int sum = 0;
        int sum1 = 0;
         int[] res= new int[len];
         int[] res1= new int[len+1];
        for(int i = 0; i< digits.length; i++){
          sum +=Math.pow(10,len-i-1)*digits[i];
        }
        for(int i = 0; i

数值小时可通过,但是没有考虑到数值的范围。待会再改:

 

 

一把辛酸泪…………………………

 

你可能感兴趣的:(算法相关)