{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "5095334c03264298b61cdf36a5f3602d",
  "keywords": "数组,数学",
  "title": "加一",
  "desc": [
    {
      "content": "\n<p>给定一个由 <strong>整数 </strong>组成的<strong> 非空</strong> 数组所表示的非负整数，在该数的基础上加一。</p><p>最高位数字存放在数组的首位， 数组中每个元素只存储<strong>单个</strong>数字。</p><p>你可以假设除了整数 0 之外，这个整数不会以零开头。</p><p> </p><p><strong>示例 1：</strong></p><pre><strong>输入：</strong>digits = [1,2,3]<strong><br />输出：</strong>[1,2,4]<strong><br />解释：</strong>输入数组表示数字 123。</pre><p><strong>示例 2：</strong></p><pre><strong>输入：</strong>digits = [4,3,2,1]<strong><br />输出：</strong>[4,3,2,2]<strong><br />解释：</strong>输入数组表示数字 4321。</pre><p><strong>示例 3：</strong></p><pre><strong>输入：</strong>digits = [0]<strong><br />输出：</strong>[1]</pre><p> </p><p><strong>提示：</strong></p><ul>\t<li><code>1 <= digits.length <= 100</code></li>\t<li><code>0 <= digits[i] <= 9</code></li></ul>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "java"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ]
  ],
  "template": {
    "content": "class Solution {\n\tpublic int[] plusOne(int[] digits) {\n\t\tint i = digits.length - 1;\n\t\twhile (i >= 0 && (digits[i] = digits[i] + 1) == 10) {\n\t\t\tdigits[i] = 0;\n\t\t\ti--;\n\t\t}\n\t\tif (digits[0] == 0) {\n\t\t\tint[] temp = new int[digits.length + 1];\n\t\t\ttemp[0] = 1;\n\t\t\treturn temp;\n\t\t}\n\t\treturn digits;\n\t}\n}",
    "language": "java"
  },
  "node_id": "dailycode-4a30eebe19474c4fb0a387ab45a684de",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600469823"
}