当前位置:网站首页>leetcode 665. Non-decreasing Array
leetcode 665. Non-decreasing Array
2022-07-31 18:19:00 【InfoQ】
I. Topic effect
- n == nums.length
- 1 <= n <= 104
- -105 <= nums[i] <= 105
Second, problem-solving ideas
Three, problem solving method
3.1 Java implementation
public class Solution {
public boolean checkPossibility(int[] nums) {
int cnt = 1;
for (int i = 1; i < nums.length; i++) {
if (nums[i] < nums[i - 1]) {
if(cnt == 0) {
return false;
}
cnt--;
if (i == 1) {
nums[i - 1] =nums[i];
} else if (nums[i] >= nums[i - 2]) {
nums[i - 1] = nums[i];
} else {
nums[i] = nums[i - 1];
}
}
}
return true;
}
}
Four, Summary Notes
- 2022/7/31 The weather is very hot today
边栏推荐
猜你喜欢

1161. 最大层内元素和 : 层序遍历运用题
Cache and Database Consistency Solutions

IP protocol from 0 to 1
![[Network Communication 3] Advantech Gateway Modbus Service Settings](/img/ec/e9e1d9a374183ecaa8a8c9437ec82c.png)
[Network Communication 3] Advantech Gateway Modbus Service Settings

全平台GPU通用AI视频补帧超分教程

MySQL---运算符

MySQL---子查询

The new telecom "routine", my dad was tricked!
![[pytorch] pytorch automatic derivation, Tensor and Autograd](/img/99/c9632a7d3f70a13e1e26b9aa67b8b9.png)
[pytorch] pytorch automatic derivation, Tensor and Autograd

go mode tidy出现报错go warning “all“ matched no packages
随机推荐
MySQL common statements
spark报错OutOfMemory「建议收藏」
Go record - slice
MySQL---创建和管理数据库和数据表
Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)
TestCafe之如何进行调试
useragent怎么获取
matplotlib ax bar color 设置ax bar的颜色、 透明度、label legend
Golang 小数操作之判断几位小数点与四舍五入
【愚公系列】2022年07月 Go教学课程 023-Go容器之列表
联邦学习:联邦场景下的多源知识图谱嵌入
Intelligent bin (9) - vibration sensor (raspberries pie pico implementation)
MySQL---运算符
[TypeScript] OOP
21.支持向量机—核函数的介绍
GateWay实现负载均衡
如何识别假爬虫?
【愚公系列】2022年07月 Go教学课程 021-Go容器之切片操作
你辛辛苦苦写的文章可能不是你的原创
几款永久免费内网穿透,好用且简单(内网穿透教程)