当前位置:网站首页>LeetCode_ 66 (plus one)
LeetCode_ 66 (plus one)
2022-07-01 04:44:00 【***】
Title Description :
Given a by Integers Composed of Non empty The nonnegative integer represented by an array , Add one to the number .
The highest digit is placed at the top of the array , Each element in the array stores only a single number .
You can assume that except for integers 0 outside , This integer will not start with zero .
Example 1:
Input :digits = [1,2,3]
Output :[1,2,4]
explain : Input array represents number 123.
Example 2:
Input :digits = [4,3,2,1]
Output :[4,3,2,2]
explain : Input array represents number 4321.
Example 3:
Input :digits = [0]
Output :[1]
Tips :
1 <= digits.length <= 100
0 <= digits[i] <= 9
class Solution {
public int[] plusOne(int[] digits) {
for (int i = digits.length-1; i >=0 ; i--) {
if(digits[i]!=9){
digits[i]++;
return digits;
}
digits[i]=0;
}
int[] res=new int[digits.length+1];
res[0]=1;
return res;
}
}
边栏推荐
- C language games (I) -- guessing games
- Seven crimes of counting software R & D Efficiency
- Why is Hong Kong server most suitable for overseas website construction
- CF1638E. Colorful operations Kodori tree + differential tree array
- MySQL winter vacation self-study 2022 12 (5)
- Maixll-Dock 使用方法
- 神经网络的基本骨架-nn.Moudle的使用
- Basic usage, principle and details of session
- AssertionError assert I.ndim == 4 and I.shape[1] == 3
- OdeInt与GPU
猜你喜欢

神经网络-使用Sequential搭建神经网络

2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities

The design points of voice dialogue system and the importance of multi round dialogue
![[2020 overview] overview of link prediction based on knowledge map embedding](/img/69/22983c5f37bb67a8dc0e2b87c73238.jpg)
[2020 overview] overview of link prediction based on knowledge map embedding

Why is Internet thinking not suitable for AI products?

Section 27 remote access virtual private network workflow and experimental demonstration

测量三相永磁同步电机的交轴直轴电感

Difficulties in the development of knowledge map & the importance of building industry knowledge map
![[pat (basic level) practice] - [simple simulation] 1064 friends](/img/37/0ef0f8aae15ae574be1d76c97497c9.jpg)
[pat (basic level) practice] - [simple simulation] 1064 friends

STM32扩展板 温度传感器和温湿度传感器的使用
随机推荐
Matters behind the construction of paint testing laboratory
[FTP] common FTP commands, updating continuously
扩展-Fragment
【硬十宝典】——1.【基础知识】电源的分类
【FTP】FTP常用命令,持续更新中……
常用的Transforms中的方法
Construction of Meizhou nursing laboratory: equipment configuration
Annual inventory review of Alibaba cloud's observable practices in 2021
Introduction to JVM stack and heap
PgSQL failed to start after installation
Daily algorithm & interview questions, 28 days of special training in large factories - the 13th day (array)
Basic exercise of test questions hexadecimal to decimal
神经网络-最大池化的使用
[pat (basic level) practice] - [simple simulation] 1064 friends
Advanced application of ES6 modular and asynchronous programming
STM32 photoresistor sensor & two channel AD acquisition
How to use maixll dock
RDF query language SPARQL
Web server: how to choose a good web server these five aspects should be paid attention to
C language games (I) -- guessing games