- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1909.java
25 lines (24 loc) · 819 Bytes
/
_1909.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
packagecom.fishercoder.solutions.secondthousand;
publicclass_1909 {
publicstaticclassSolution1 {
/*
* credit: https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing/discuss/1298827/Java-Short
*/
publicbooleancanBeIncreasing(int[] nums) {
booleanremoved = false;
for (inti = 1; i < nums.length; i++) {
if (nums[i] <= nums[i - 1]) {
if (removed) {
returnfalse;
} else {
removed = true;
}
if (i > 1 && nums[i] <= nums[i - 2]) {
nums[i] = nums[i - 1];
}
}
}
returntrue;
}
}
}