当前位置:网站首页>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;
}
}
边栏推荐
- Registration for R2 mobile pressure vessel filling test in 2022 and R2 mobile pressure vessel filling free test questions
- About the transmission pipeline of stage in spark
- How to choose the right server for website data collection?
- RDF query language SPARQL
- Overview of the construction details of Meizhou veterinary laboratory
- CF1638E. Colorful operations Kodori tree + differential tree array
- Ten wastes of software research and development: the other side of research and development efficiency
- 2022危险化学品生产单位安全生产管理人员题库及答案
- Grey correlation cases and codes
- 2022-02-15 (399. Division evaluation)
猜你喜欢
2022年聚合工艺考试题及模拟考试
Question bank and answers for chemical automation control instrument operation certificate examination in 2022
Registration of P cylinder filling examination in 2022 and analysis of P cylinder filling
2022年T电梯修理题库及模拟考试
2022 Shanghai safety officer C certificate examination question simulation examination question bank and answers
How to use maixll dock
STM32 photoresistor sensor & two channel AD acquisition
神经网络的基本骨架-nn.Moudle的使用
Kodori tree board
Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com. and
随机推荐
细数软件研发效能的七宗罪
2022年煤气考试题库及在线模拟考试
Talk about testdeploy
Summary of acl2021 information extraction related papers
I also gave you the MySQL interview questions of Boda factory. If you need to come in and take your own
Simple implementation of slf4j
VIM easy to use tutorial
STM32扩展板 数码管显示
AssertionError assert I.ndim == 4 and I.shape[1] == 3
Advanced application of ES6 modular and asynchronous programming
Leecode question brushing record 1332 delete palindrome subsequence
slf4j 简单实现
2022 hoisting machinery command registration examination and hoisting machinery command examination registration
Common UNIX Operation and maintenance commands of shell
How to do the performance pressure test of "Health Code"
先有网络模型的使用及修改
[pat (basic level) practice] - [simple simulation] 1064 friends
[2020 overview] overview of link prediction based on knowledge map embedding
Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation 阅读笔记
Quelques outils dont les chiens scientifiques pourraient avoir besoin