Skip to content

Commit c42f7ed

Browse files
authored
Create Remove One Element to Make the Array Strictly Increasing.java
1 parent 779fc5f commit c42f7ed

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public boolean canBeIncreasing(int[] nums) {
3+
boolean removed = false;
4+
for (int i = 1; i < nums.length; i++) {
5+
if (nums[i] <= nums[i - 1]) {
6+
if (removed) {
7+
return false;
8+
}
9+
removed = true;
10+
if (i > 1 && nums[i] <= nums[i - 2]) {
11+
nums[i] = nums[i - 1];
12+
}
13+
}
14+
}
15+
return true;
16+
}
17+
}

0 commit comments

Comments
 (0)