首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
加一
[编程题]加一
热度指数:12980
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
给出用数字数组表示的
一个
非负整数
,请对该整数加1。
示例1
输入
[1]
输出
[2]
示例2
输入
[1,2,3]
输出
[1,2,4]
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(39)
分享
提交结果有问题?
81个回答
3篇题解
开通博客
诗云panther
发表于 2021-08-21 15:05:38
class Solution {public: /* * * @param A int整型一维数组 * @param n int A数组长度 * @param target int整型 * @return int整型vector */ ve
展开全文
牛客564594591号
发表于 2022-01-06 17:23:17
傻瓜式写法 import java.util.*; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.math.BigInteger; public clas
展开全文
华科不平凡
发表于 2020-09-26 16:07:52
关键在于看懂题目的意思:将一个数组表示的大数加一 所以问题的关键在于模拟进位,步骤如下: 拷贝整个数组 从数组最后一个数开始加1 如果有进位,将下一个数加一 如此循环,如果第一个元素仍有进位,向最前面插入一个元素 代码如下: // // Created by jt on 2020/9/26.
展开全文
问题信息
数组
难度:
81条回答
39收藏
27732浏览
热门推荐
通过挑战的用户
查看代码
这一世
2022-12-08 07:31:51
球球了2023...
2022-10-11 00:46:36
牛客93929...
2022-10-10 15:57:19
牛客1891197号
2022-10-01 15:56:20
forwgzz
2022-09-21 20:45:38
相关试题
校门外的树
枚举
NOIP复赛
评论
(1)
平方根
过关题目
语言题
评论
(1)
下面关于 Spring Cloud...
Spring
评论
(1)
请回答问题
图形推理
评论
(1)
下面代码的输出结果 public ...
Java
评论
(1)
加一
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * * @param digits int整型一维数组 * @return int整型一维数组 */ public int[] plusOne (int[] digits) { // write code here } }
class Solution { public: /** * * @param digits int整型vector * @return int整型vector */ vector
plusOne(vector
& digits) { // write code here } };
# # # @param digits int整型一维数组 # @return int整型一维数组 # class Solution: def plusOne(self , digits ): # write code here
/** * * @param digits int整型一维数组 * @return int整型一维数组 */ function plusOne( digits ) { // write code here } module.exports = { plusOne : plusOne };
# # # @param digits int整型一维数组 # @return int整型一维数组 # class Solution: def plusOne(self , digits ): # write code here
package main /** * * @param digits int整型一维数组 * @return int整型一维数组 */ func plusOne( digits []int ) []int { // write code here }
[1]
[2]
[1,2,3]
[1,2,4]