Plus One

作者: aemaeth | 来源:发表于2016-03-13 16:27 被阅读0次

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.

int* plusOne(int* digits, int digitsSize, int* returnSize) { for(int i=digitsSize-1;i>=0;i--){ if(digits[i]==9){ digits[i]=0; } else{ digits[i]+=1; *returnSize=digitsSize; return digits; } } *returnSize=digitsSize+1; for(int i=0;i<*returnSize;i++) digits[i]=0; digits[0]=1; return digits; }

相关文章

  • LeetCode 66-70

    66. Plus One[https://leetcode-cn.com/problems/plus-one/] ...

  • 66. Plus One

    66. Plus One 题目:https://leetcode.com/problems/plus-one/ 难...

  • Plus One

    https://leetcode.com/problems/plus-one/description/ 思路 反向...

  • Plus One

  • one plus

    Easy, Math Question 一个数以digit序列的形式给出,加一返回对应digit序列 Notes ...

  • Plus One

    Given a non-negative number represented as an array of di...

  • plus one

    question: answer: 之前蠢了,打印数组用Arrays.toString()方便很多直接在Syste...

  • Plus one

    Given a non-negative number represented as an array of di...

  • Plus one

    Given a non-negative number represented as an array of di...

  • Plus One

    题目描述Given a non-empty array of digits representing a non-...

网友评论

      本文标题:Plus One

      本文链接:https://www.haomeiwen.com/subject/wpxflttx.html