Skip to content

Commit 4d7e3a4

Browse files
add 1909
1 parent 6366297 commit 4d7e3a4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _If you like this project, please leave me a star._ ★
99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
1111
|1910|[Remove All Occurrences of a Substring](https://leetcode.com/problems/remove-all-occurrences-of-a-substring/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1904.java) ||Medium|String|
12+
|1909|[Remove One Element to Make the Array Strictly Increasing](https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1909.java) ||Easy|Array|
1213
|1904|[The Number of Full Rounds You Have Played](https://leetcode.com/problems/the-number-of-full-rounds-you-have-played/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1904.java) ||Medium|String, Greedy|
1314
|1903|[Largest Odd Number in String](https://leetcode.com/problems/largest-odd-number-in-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1903.java) ||Easy|Greedy|
1415
|1897|[Redistribute Characters to Make All Strings Equal](https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1897.java) ||Easy|String, Greedy|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1909 {
4+
public static class Solution1 {
5+
/**
6+
* credit: https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing/discuss/1298827/Java-Short
7+
*/
8+
public boolean canBeIncreasing(int[] nums) {
9+
boolean removed = false;
10+
for (int i = 1; i < nums.length; i++) {
11+
if (nums[i] <= nums[i - 1]) {
12+
if (removed) {
13+
return false;
14+
} else {
15+
removed = true;
16+
}
17+
if (i > 1 && nums[i] <= nums[i - 2]) {
18+
nums[i] = nums[i - 1];
19+
}
20+
}
21+
}
22+
return true;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)