当前位置:网站首页>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;
}
}
边栏推荐
- Shell之一键自动部署Redis任意版本
- 2022-02-15 (399. Division evaluation)
- 2022 hoisting machinery command registration examination and hoisting machinery command examination registration
- STM32扩展板 温度传感器和温湿度传感器的使用
- VR线上展览所具备应用及特色
- Dual contractual learning: text classification via label aware data augmentation reading notes
- LM small programmable controller software (based on CoDeSys) note 19: errors do not match the profile of the target
- Simple implementation of slf4j
- Why is Internet thinking not suitable for AI products?
- Kodori tree board
猜你喜欢

2022 t elevator repair question bank and simulation test

无器械健身

Section 27 remote access virtual private network workflow and experimental demonstration

STM32 光敏电阻传感器&两路AD采集

The junior college students were angry for 32 days, four rounds of interviews, five hours of soul torture, and won Ali's offer with tears

pytorch中常用数据集的使用方法

About the transmission pipeline of stage in spark

Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation 阅读笔记

2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis

Maixll-Dock 快速上手
随机推荐
LM小型可编程控制器软件(基于CoDeSys)笔记二十:plc通过驱动器控制步进电机
2022-02-15 (399. Division evaluation)
神经网络-使用Sequential搭建神经网络
Daily question - line 10
C language games (I) -- guessing games
Announcement on the list of Guangdong famous high-tech products to be selected in 2021
Maixll dock quick start
Registration for R2 mobile pressure vessel filling test in 2022 and R2 mobile pressure vessel filling free test questions
神经网络-卷积层
The design points of voice dialogue system and the importance of multi round dialogue
CUDA development and debugging tool
TCP server communication flow
Annual inventory review of Alibaba cloud's observable practices in 2021
Web server: how to choose a good web server these five aspects should be paid attention to
Odeint et GPU
先有网络模型的使用及修改
How to choose the right server for website data collection?
最长递增子序列及最优解、动物总重量问题
STM32扩展板 数码管显示
CF1638E. Colorful operations Kodori tree + differential tree array